@@ -2951,18 +2951,18 @@ pushdecl_top_level (tree x)
}
static void
-implicit_decl_warning (tree id, tree olddecl)
+implicit_decl_warning (location_t loc, tree id, tree olddecl)
{
if (warn_implicit_function_declaration)
{
bool warned;
if (flag_isoc99)
- warned = pedwarn (input_location, OPT_Wimplicit_function_declaration,
+ warned = pedwarn (loc, OPT_Wimplicit_function_declaration,
"implicit declaration of function %qE", id);
else
- warned = warning (OPT_Wimplicit_function_declaration,
- G_("implicit declaration of function %qE"), id);
+ warned = warning_at (loc, OPT_Wimplicit_function_declaration,
+ G_("implicit declaration of function %qE"), id);
if (olddecl && warned)
locate_old_decl (olddecl);
}
@@ -3015,7 +3015,7 @@ implicitly_declare (location_t loc, tree functionid)
then recycle the old declaration but with the new type. */
if (!C_DECL_IMPLICIT (decl))
{
- implicit_decl_warning (functionid, decl);
+ implicit_decl_warning (loc, functionid, decl);
C_DECL_IMPLICIT (decl) = 1;
}
if (DECL_BUILT_IN (decl))
@@ -3052,7 +3052,7 @@ implicitly_declare (location_t loc, tree functionid)
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
C_DECL_IMPLICIT (decl) = 1;
- implicit_decl_warning (functionid, 0);
+ implicit_decl_warning (loc, functionid, 0);
asmspec_tree = maybe_apply_renaming_pragma (decl, /*asmname=*/NULL);
if (asmspec_tree)
set_user_assembler_name (decl, TREE_STRING_POINTER (asmspec_tree));
@@ -0,0 +1,10 @@
+/* PR c/61852 */
+/* { dg-do compile } */
+/* { dg-options "-Wimplicit-function-declaration" } */
+
+int
+f (int a)
+{
+ int b = a + a + a + ff (a); /* { dg-warning "23:implicit declaration of function" } */
+ return b;
+}