+2016-08-30 David Malcolm <dmalcolm@redhat.com>
+
+ * diagnostic-show-locus.c (test_one_liner_fixit_insert): Remove
+ redundant location param.
+ (test_one_liner_fixit_remove): Likewise.
+ (test_one_liner_fixit_replace): Likewise.
+ (test_one_liner_fixit_replace_equal_secondary_range): Likewise.
+ * gcc-rich-location.c
+ (gcc_rich_location::add_fixit_misspelled_id): Eliminate call to
+ get_range_from_loc. Drop overload taking a const char *.
+ * gcc-rich-location.h
+ (gcc_rich_location::add_fixit_misspelled_id): Drop overload taking
+ a const char *.
+
2016-08-30 Szabolcs Nagy <szabolcs.nagy@arm.com>
* config/linux.c (linux_libc_has_function): Return true on musl.
+2016-08-30 David Malcolm <dmalcolm@redhat.com>
+
+ * c-decl.c (implicit_decl_warning): Use add_fixit_replace
+ rather than add_fixit_misspelled_id.
+ (undeclared_variable): Likewise.
+ * c-parser.c (c_parser_declaration_or_fndef): Likewise. Remove
+ now-redundant "here" params from add_fixit_insert method calls.
+ (c_parser_parameter_declaration): Likewise.
+ * c-typeck.c (build_component_ref): Remove now-redundant range
+ param from add_fixit_replace method calls.
+
2016-08-25 Marek Polacek <polacek@redhat.com>
* c-typeck.c (parser_build_binary_op): Pass LHS to
if (hint)
{
gcc_rich_location richloc (loc);
- richloc.add_fixit_misspelled_id (loc, hint);
+ richloc.add_fixit_replace (hint);
warned = pedwarn_at_rich_loc
(&richloc, OPT_Wimplicit_function_declaration,
"implicit declaration of function %qE; did you mean %qs?",
if (hint)
{
gcc_rich_location richloc (loc);
- richloc.add_fixit_misspelled_id (loc, hint);
+ 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?"),
if (guessed_id)
{
gcc_rich_location richloc (loc);
- richloc.add_fixit_misspelled_id (loc, guessed_id);
+ richloc.add_fixit_replace (guessed_id);
error_at_rich_loc (&richloc,
"%qE undeclared here (not in a function);"
" did you mean %qs?",
if (guessed_id)
{
gcc_rich_location richloc (loc);
- richloc.add_fixit_misspelled_id (loc, guessed_id);
+ richloc.add_fixit_replace (guessed_id);
error_at_rich_loc
(&richloc,
"%qE undeclared (first use in this function);"
if (tag_exists_p (RECORD_TYPE, name))
{
/* This is not C++ with its implicit typedef. */
- richloc.add_fixit_insert (here, "struct");
+ richloc.add_fixit_insert ("struct");
error_at_rich_loc (&richloc,
"unknown type name %qE;"
" use %<struct%> keyword to refer to the type",
}
else if (tag_exists_p (UNION_TYPE, name))
{
- richloc.add_fixit_insert (here, "union");
+ richloc.add_fixit_insert ("union");
error_at_rich_loc (&richloc,
"unknown type name %qE;"
" use %<union%> keyword to refer to the type",
}
else if (tag_exists_p (ENUMERAL_TYPE, name))
{
- richloc.add_fixit_insert (here, "enum");
+ richloc.add_fixit_insert ("enum");
error_at_rich_loc (&richloc,
"unknown type name %qE;"
" use %<enum%> keyword to refer to the type",
const char *hint = lookup_name_fuzzy (name, FUZZY_LOOKUP_TYPENAME);
if (hint)
{
- richloc.add_fixit_misspelled_id (here, hint);
+ richloc.add_fixit_replace (hint);
error_at_rich_loc (&richloc,
"unknown type name %qE; did you mean %qs?",
name, hint);
if (hint)
{
gcc_rich_location richloc (token->location);
- richloc.add_fixit_misspelled_id (token->location, hint);
+ richloc.add_fixit_replace (hint);
error_at_rich_loc (&richloc,
"unknown type name %qE; did you mean %qs?",
token->value, hint);
where the user has confused "." vs "->". */
rich_location richloc (line_table, loc);
/* "loc" should be the "." token. */
- richloc.add_fixit_replace (source_range::from_location (loc), "->");
+ richloc.add_fixit_replace ("->");
error_at_rich_loc (&richloc,
"%qE is a pointer; did you mean to use %<->%>?",
datum);
+2016-08-30 David Malcolm <dmalcolm@redhat.com>
+
+ * name-lookup.c (suggest_alternatives_for): Use add_fixit_replace
+ rather than add_fixit_misspelled_id.
+ * parser.c (cp_parser_diagnose_invalid_type_name): Likewise.
+
2016-08-29 Jason Merrill <jason@redhat.com>
PR c++/77379
if (fuzzy_name)
{
gcc_rich_location richloc (location);
- richloc.add_fixit_misspelled_id (location, fuzzy_name);
+ richloc.add_fixit_replace (fuzzy_name);
inform_at_rich_loc (&richloc, "suggested alternative: %qs",
fuzzy_name);
}
if (suggestion)
{
gcc_rich_location richloc (location);
- richloc.add_fixit_misspelled_id (location, suggestion);
+ richloc.add_fixit_replace (suggestion);
error_at_rich_loc (&richloc,
"%qE does not name a type; did you mean %qs?",
id, suggestion);
test_diagnostic_context dc;
location_t caret = linemap_position_for_column (line_table, 7);
rich_location richloc (line_table, caret);
- richloc.add_fixit_insert (caret, "&");
+ richloc.add_fixit_insert ("&");
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ ("\n"
" foo = bar.field;\n"
location_t finish = linemap_position_for_column (line_table, 15);
location_t dot = make_location (start, start, finish);
rich_location richloc (line_table, dot);
- source_range range;
- range.m_start = start;
- range.m_finish = finish;
- richloc.add_fixit_remove (range);
+ richloc.add_fixit_remove ();
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ ("\n"
" foo = bar.field;\n"
location_t finish = linemap_position_for_column (line_table, 15);
location_t field = make_location (start, start, finish);
rich_location richloc (line_table, field);
- source_range range;
- range.m_start = start;
- range.m_finish = finish;
- richloc.add_fixit_replace (range, "m_field");
+ richloc.add_fixit_replace ("m_field");
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ ("\n"
" foo = bar.field;\n"
rich_location richloc (line_table, equals);
location_t field = make_location (start, start, finish);
richloc.add_range (field, false);
- source_range range;
- range.m_start = start;
- range.m_finish = finish;
- richloc.add_fixit_replace (range, "m_field");
+ richloc.add_fixit_replace (field, "m_field");
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
/* The replacement range is indicated in the annotation line,
so it shouldn't be indicated via an additional underline. */
{
gcc_assert (TREE_CODE (hint_id) == IDENTIFIER_NODE);
- source_range misspelled_token_range
- = 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);
+ add_fixit_replace (misspelled_token_loc, IDENTIFIER_POINTER (hint_id));
}
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 */
+2016-08-30 David Malcolm <dmalcolm@redhat.com>
+
+ * include/line-map.h (rich_location::add_fixit_insert): Add
+ comments. Add overload omitting the source_location param.
+ (rich_location::add_fixit_remove): Add comments. Add overloads
+ omitting the range, and accepting a source_location.
+ (rich_location::add_fixit_replace): Likewise.
+ * line-map.c (rich_location::add_fixit_insert): Add comments. Add
+ overload omitting the source_location param.
+ (rich_location::add_fixit_remove): Add comments. Add overloads
+ omitting the range, and accepting a source_location.
+ (rich_location::add_fixit_replace): Likewise.
+
2016-08-26 David Malcolm <dmalcolm@redhat.com>
* include/line-map.h (get_pure_location): New decl.
override_column (int column);
/* Fix-it hints. */
+
+ /* Methods for adding insertion fix-it hints. */
+
+ /* Suggest inserting NEW_CONTENT at the primary range's caret. */
+ void
+ add_fixit_insert (const char *new_content);
+
+ /* Suggest inserting NEW_CONTENT at WHERE. */
void
add_fixit_insert (source_location where,
const char *new_content);
+ /* Methods for adding removal fix-it hints. */
+
+ /* Suggest removing the content covered by range 0. */
+ void
+ add_fixit_remove ();
+
+ /* Suggest removing the content covered between the start and finish
+ of WHERE. */
+ void
+ add_fixit_remove (source_location where);
+
+ /* Suggest removing the content covered by SRC_RANGE. */
void
add_fixit_remove (source_range src_range);
+ /* Methods for adding "replace" fix-it hints. */
+
+ /* Suggest replacing the content covered by range 0 with NEW_CONTENT. */
+ void
+ add_fixit_replace (const char *new_content);
+
+ /* Suggest replacing the content between the start and finish of
+ WHERE with NEW_CONTENT. */
+ void
+ add_fixit_replace (source_location where,
+ const char *new_content);
+
+ /* Suggest replacing the content covered by SRC_RANGE with
+ NEW_CONTENT. */
void
add_fixit_replace (source_range src_range,
const char *new_content);
m_have_expanded_location = false;
}
+/* Methods for adding insertion fix-it hints. */
+
+/* Add a fixit-hint, suggesting insertion of NEW_CONTENT
+ at the primary range's caret location. */
+
+void
+rich_location::add_fixit_insert (const char *new_content)
+{
+ add_fixit_insert (get_loc (), new_content);
+}
+
/* Add a fixit-hint, suggesting insertion of NEW_CONTENT
at WHERE. */
= new fixit_insert (where, new_content);
}
+/* Methods for adding removal fix-it hints. */
+
+/* Add a fixit-hint, suggesting removal of the content covered
+ by range 0. */
+
+void
+rich_location::add_fixit_remove ()
+{
+ add_fixit_remove (get_loc ());
+}
+
+/* Add a fixit-hint, suggesting removal of the content between
+ the start and finish of WHERE. */
+
+void
+rich_location::add_fixit_remove (source_location where)
+{
+ source_range range = get_range_from_loc (m_line_table, where);
+ add_fixit_remove (range);
+}
+
/* Add a fixit-hint, suggesting removal of the content at
SRC_RANGE. */
return column_b == column_a + 1;
}
+/* Add a fixit-hint, suggesting replacement of the content covered
+ by range 0 with NEW_CONTENT. */
+
+void
+rich_location::add_fixit_replace (const char *new_content)
+{
+ add_fixit_replace (get_loc (), new_content);
+}
+
+/* Methods for adding "replace" fix-it hints. */
+
+/* Add a fixit-hint, suggesting replacement of the content between
+ the start and finish of WHERE with NEW_CONTENT. */
+
+void
+rich_location::add_fixit_replace (source_location where,
+ const char *new_content)
+{
+ source_range range = get_range_from_loc (m_line_table, where);
+ add_fixit_replace (range, new_content);
+}
+
/* Add a fixit-hint, suggesting replacement of the content at
SRC_RANGE with NEW_CONTENT. */