aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2017-03-11 10:26:35 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2017-03-11 10:26:35 +0000
commit85059a38cba2e84d0242f5d0b835ab95ad4b4965 (patch)
tree56b12a961b5b9ca114725cb110936feb7accade6 /gcc/c
parent2f6f187a86652b0a1d8bac2eda09e25b515c2f46 (diff)
downloadgcc-85059a38cba2e84d0242f5d0b835ab95ad4b4965.zip
gcc-85059a38cba2e84d0242f5d0b835ab95ad4b4965.tar.gz
gcc-85059a38cba2e84d0242f5d0b835ab95ad4b4965.tar.bz2
* c-decl.c (implicit_decl_warning): Add a comment. Fix formatting.
From-SVN: r246069
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog4
-rw-r--r--gcc/c/c-decl.c73
2 files changed, 44 insertions, 33 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index df4f65d..b138346 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,7 @@
+2017-03-11 Marek Polacek <polacek@redhat.com>
+
+ * c-decl.c (implicit_decl_warning): Add a comment. Fix formatting.
+
2017-03-10 David Malcolm <dmalcolm@redhat.com>
PR translation/79848
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 0f10208..a0dc5bc 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -3117,45 +3117,52 @@ pushdecl_top_level (tree x)
return x;
}
+
+/* Issue a warning about implicit function declaration. ID is the function
+ identifier, OLDDECL is a declaration of the function in a different scope,
+ or NULL_TREE. */
+
static void
implicit_decl_warning (location_t loc, tree id, tree olddecl)
{
- if (warn_implicit_function_declaration)
- {
- bool warned;
- const char *hint = NULL;
- if (!olddecl)
- hint = lookup_name_fuzzy (id, FUZZY_LOOKUP_FUNCTION_NAME);
+ if (!warn_implicit_function_declaration)
+ return;
- if (flag_isoc99)
- if (hint)
- {
- gcc_rich_location richloc (loc);
- richloc.add_fixit_replace (hint);
- warned = pedwarn_at_rich_loc
- (&richloc, OPT_Wimplicit_function_declaration,
- "implicit declaration of function %qE; did you mean %qs?",
- id, hint);
- }
- else
- warned = pedwarn (loc, OPT_Wimplicit_function_declaration,
- "implicit declaration of function %qE", id);
+ bool warned;
+ const char *hint = NULL;
+ if (!olddecl)
+ hint = lookup_name_fuzzy (id, FUZZY_LOOKUP_FUNCTION_NAME);
+
+ if (flag_isoc99)
+ {
+ if (hint)
+ {
+ gcc_rich_location richloc (loc);
+ richloc.add_fixit_replace (hint);
+ warned = pedwarn_at_rich_loc
+ (&richloc, OPT_Wimplicit_function_declaration,
+ "implicit declaration of function %qE; did you mean %qs?",
+ id, hint);
+ }
else
- if (hint)
- {
- gcc_rich_location richloc (loc);
- richloc.add_fixit_replace (hint);
- warned = warning_at_rich_loc
- (&richloc, OPT_Wimplicit_function_declaration,
- G_("implicit declaration of function %qE; did you mean %qs?"),
- id, hint);
- }
- else
- warned = warning_at (loc, OPT_Wimplicit_function_declaration,
- G_("implicit declaration of function %qE"), id);
- if (olddecl && warned)
- locate_old_decl (olddecl);
+ warned = pedwarn (loc, OPT_Wimplicit_function_declaration,
+ "implicit declaration of function %qE", id);
}
+ else if (hint)
+ {
+ gcc_rich_location richloc (loc);
+ richloc.add_fixit_replace (hint);
+ warned = warning_at_rich_loc
+ (&richloc, OPT_Wimplicit_function_declaration,
+ G_("implicit declaration of function %qE; did you mean %qs?"),
+ id, hint);
+ }
+ else
+ warned = warning_at (loc, OPT_Wimplicit_function_declaration,
+ G_("implicit declaration of function %qE"), id);
+
+ if (olddecl && warned)
+ locate_old_decl (olddecl);
}
/* This function represents mapping of a function code FCODE