aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-07-20 13:42:51 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-07-20 13:42:51 +0000
commitde6a69eea8eda77b8944c538c70620e7d25d5b2b (patch)
tree9b8be09a9ce188671750b4f8e76df99ec445a22c /gcc/c
parentffc2284012c94620bdbffb5276a264bd7fcf7d91 (diff)
downloadgcc-de6a69eea8eda77b8944c538c70620e7d25d5b2b.zip
gcc-de6a69eea8eda77b8944c538c70620e7d25d5b2b.tar.gz
gcc-de6a69eea8eda77b8944c538c70620e7d25d5b2b.tar.bz2
C: convert return type of lookup_name_fuzzy from tree to const char *
gcc/c-family/ChangeLog: * c-common.h (lookup_name_fuzzy): Convert return type from tree to const char *. gcc/c/ChangeLog: * c-decl.c (implicit_decl_warning): Update for conversion of return type of lookup_name_fuzzy to const char *. (undeclared_variable): Likewise. (lookup_name_fuzzy): Convert return type from tree to const char *. * c-parser.c (c_parser_declaration_or_fndef): Update for conversion of return type of lookup_name_fuzzy to const char *. (c_parser_parameter_declaration): Likewise. gcc/ChangeLog: * gcc-rich-location.c (gcc_rich_location::add_fixit_misspelled_id): New overload, taking a const char *. * gcc-rich-location.h (gcc_rich_location::add_fixit_misspelled_id): Likewise. From-SVN: r238517
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog11
-rw-r--r--gcc/c/c-decl.c22
-rw-r--r--gcc/c/c-parser.c10
3 files changed, 29 insertions, 14 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index bc1e955..d322761 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,14 @@
+2016-07-20 David Malcolm <dmalcolm@redhat.com>
+
+ * c-decl.c (implicit_decl_warning): Update for conversion of
+ return type of lookup_name_fuzzy to const char *.
+ (undeclared_variable): Likewise.
+ (lookup_name_fuzzy): Convert return type from tree to
+ const char *.
+ * c-parser.c (c_parser_declaration_or_fndef): Update for
+ conversion of return type of lookup_name_fuzzy to const char *.
+ (c_parser_parameter_declaration): Likewise.
+
2016-07-15 Cesar Philippidis <cesar@codesourcery.com>
* c-parser.c (c_parser_oacc_declare): Don't scan for
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 955c0e8..d9f2dd7 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -3088,7 +3088,7 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl)
if (warn_implicit_function_declaration)
{
bool warned;
- tree hint = NULL_TREE;
+ const char *hint = NULL;
if (!olddecl)
hint = lookup_name_fuzzy (id, FUZZY_LOOKUP_FUNCTION_NAME);
@@ -3099,7 +3099,7 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl)
richloc.add_fixit_misspelled_id (loc, hint);
warned = pedwarn_at_rich_loc
(&richloc, OPT_Wimplicit_function_declaration,
- "implicit declaration of function %qE; did you mean %qE?",
+ "implicit declaration of function %qE; did you mean %qs?",
id, hint);
}
else
@@ -3112,7 +3112,7 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl)
richloc.add_fixit_misspelled_id (loc, hint);
warned = warning_at_rich_loc
(&richloc, OPT_Wimplicit_function_declaration,
- G_("implicit declaration of function %qE;did you mean %qE?"),
+ G_("implicit declaration of function %qE;did you mean %qs?"),
id, hint);
}
else
@@ -3433,14 +3433,14 @@ undeclared_variable (location_t loc, tree id)
if (current_function_decl == 0)
{
- tree guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME);
+ const char *guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME);
if (guessed_id)
{
gcc_rich_location richloc (loc);
richloc.add_fixit_misspelled_id (loc, guessed_id);
error_at_rich_loc (&richloc,
"%qE undeclared here (not in a function);"
- " did you mean %qE?",
+ " did you mean %qs?",
id, guessed_id);
}
else
@@ -3451,7 +3451,7 @@ undeclared_variable (location_t loc, tree id)
{
if (!objc_diagnose_private_ivar (id))
{
- tree guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME);
+ const char *guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME);
if (guessed_id)
{
gcc_rich_location richloc (loc);
@@ -3459,7 +3459,7 @@ undeclared_variable (location_t loc, tree id)
error_at_rich_loc
(&richloc,
"%qE undeclared (first use in this function);"
- " did you mean %qE?",
+ " did you mean %qs?",
id, guessed_id);
}
else
@@ -4010,7 +4010,7 @@ find_closest_macro_cpp_cb (cpp_reader *, cpp_hashnode *hashnode,
It also looks for start_typename keywords, to detect "singed" vs "signed"
typos. */
-tree
+const char *
lookup_name_fuzzy (tree name, enum lookup_name_fuzzy_kind kind)
{
gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
@@ -4100,7 +4100,11 @@ lookup_name_fuzzy (tree name, enum lookup_name_fuzzy_kind kind)
}
}
- return bm.get_best_meaningful_candidate ();
+ tree best = bm.get_best_meaningful_candidate ();
+ if (best)
+ return IDENTIFIER_POINTER (best);
+ else
+ return NULL;
}
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 45e32ba..8952bca 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -1698,12 +1698,12 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
}
else
{
- tree hint = lookup_name_fuzzy (name, FUZZY_LOOKUP_TYPENAME);
+ const char *hint = lookup_name_fuzzy (name, FUZZY_LOOKUP_TYPENAME);
if (hint)
{
richloc.add_fixit_misspelled_id (here, hint);
error_at_rich_loc (&richloc,
- "unknown type name %qE; did you mean %qE?",
+ "unknown type name %qE; did you mean %qs?",
name, hint);
}
else
@@ -3853,14 +3853,14 @@ c_parser_parameter_declaration (c_parser *parser, tree attrs)
c_parser_set_source_position_from_token (token);
if (c_parser_next_tokens_start_typename (parser, cla_prefer_type))
{
- tree hint = lookup_name_fuzzy (token->value, FUZZY_LOOKUP_TYPENAME);
+ const char *hint = lookup_name_fuzzy (token->value,
+ FUZZY_LOOKUP_TYPENAME);
if (hint)
{
- gcc_assert (TREE_CODE (hint) == IDENTIFIER_NODE);
gcc_rich_location richloc (token->location);
richloc.add_fixit_misspelled_id (token->location, hint);
error_at_rich_loc (&richloc,
- "unknown type name %qE; did you mean %qE?",
+ "unknown type name %qE; did you mean %qs?",
token->value, hint);
}
else