@@ -4021,7 +4021,7 @@ lookup_name_fuzzy (tree name, enum looku
for (c_scope *scope = current_scope; scope; scope = scope->outer)
for (c_binding *binding = scope->bindings; binding; binding = binding->prev)
{
- if (!binding->id)
+ if (!binding->id || binding->invisible)
continue;
/* Don't use bindings from implicitly declared functions,
as they were likely misspellings themselves. */
@@ -121,7 +121,7 @@ test_6 (enum foo f)
}
}
-/* Verify that we offer names of builtins as suggestions. */
+int snprintf (char *, __SIZE_TYPE__, const char *, ...);
void
test_7 (int i, int j)
@@ -0,0 +1,33 @@
+/* PR c/71858 */
+/* Make sure anticipated builtins are not considered before they are declared. */
+/* { dg-do compile } */
+/* { dg-options "-Wimplicit-function-declaration -fdiagnostics-show-caret" } */
+
+int sscafn (const char *, const char *, ...);
+
+int
+test_1 (const char *p)
+{
+ int i;
+ return ssacnf (p, "%d", &i); /* { dg-warning "10: implicit declaration of function .ssacnf.; did you mean .sscafn.?" } */
+ /* { dg-begin-multiline-output "" }
+ return ssacnf (p, "%d", &i);
+ ^~~~~~
+ sscafn
+ { dg-end-multiline-output "" } */
+}
+
+int scafn (const char *, ...);
+int scanf (const char *, ...);
+
+int
+test_2 (void)
+{
+ int i;
+ return sacnf ("%d", &i); /* { dg-warning "10: implicit declaration of function .sacnf.; did you mean .scanf.?" } */
+ /* { dg-begin-multiline-output "" }
+ return sacnf ("%d", &i);
+ ^~~~~
+ scanf
+ { dg-end-multiline-output "" } */
+}
@@ -2,6 +2,8 @@
/* Verify that various diagnostics show source code ranges. */
+long double nanl (const char *);
+
/* These ones merely use token ranges; they don't use tree ranges. */
void undeclared_identifier (void)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-prune-output "undeclared here \\(not in a function\\); did you mean .carg..|\[^\n\r\]* was not declared in this scope" } */
+/* { dg-prune-output "undeclared here \\(not in a function\\); did you mean .char..|\[^\n\r\]* was not declared in this scope" } */
void* my_calloc(unsigned, unsigned) __attribute__((alloc_size(1,bar))); /* { dg-warning "outside range" } */
void* my_realloc(void*, unsigned) __attribute__((alloc_size(bar))); /* { dg-warning "outside range" } */