+2016-07-20 David Malcolm <dmalcolm@redhat.com>
+
+ * 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.
+
2016-07-20 Georg-Johann Lay <avr@gjlay.de>
* target.def (addr_space): Add new diagnose_usage to hook vector.
+2016-07-20 David Malcolm <dmalcolm@redhat.com>
+
+ * c-common.h (lookup_name_fuzzy): Convert return type from tree to
+ const char *.
+
2016-07-15 Jason Merrill <jason@redhat.com>
* c-opts.c (c_common_post_options): Update -fabi-version default to 11.
/* Any name. */
FUZZY_LOOKUP_NAME
};
-extern tree lookup_name_fuzzy (tree, enum lookup_name_fuzzy_kind);
+extern const char *lookup_name_fuzzy (tree, enum lookup_name_fuzzy_kind);
extern bool vector_targets_convertible_p (const_tree t1, const_tree t2);
extern bool vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note);
+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
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);
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
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
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
{
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);
error_at_rich_loc
(&richloc,
"%qE undeclared (first use in this function);"
- " did you mean %qE?",
+ " did you mean %qs?",
id, guessed_id);
}
else
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);
}
}
- return bm.get_best_meaningful_candidate ();
+ tree best = bm.get_best_meaningful_candidate ();
+ if (best)
+ return IDENTIFIER_POINTER (best);
+ else
+ return NULL;
}
\f
}
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
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
= get_range_from_loc (line_table, misspelled_token_loc);
add_fixit_replace (misspelled_token_range, IDENTIFIER_POINTER (hint_id));
}
+
+/* As above, but with a const char * for the suggested replacement. */
+
+void
+gcc_rich_location::add_fixit_misspelled_id (location_t misspelled_token_loc,
+ const char *hint)
+{
+ gcc_assert (hint);
+
+ source_range misspelled_token_range
+ = get_range_from_loc (line_table, misspelled_token_loc);
+ add_fixit_replace (misspelled_token_range, hint);
+}
void add_fixit_misspelled_id (location_t misspelled_token_loc,
tree hint_id);
+ void add_fixit_misspelled_id (location_t misspelled_token_loc,
+ const char *hint);
};
#endif /* GCC_RICH_LOCATION_H */