@@ -1546,9 +1546,15 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
{
tree hint = lookup_name_fuzzy (c_parser_peek_token (parser)->value);
if (hint)
- error_at (here, "unknown type name %qE; did you mean %qE?",
- c_parser_peek_token (parser)->value,
- hint);
+ {
+ rich_location richloc (here);
+ richloc.add_fixit_replace (here,
+ IDENTIFIER_POINTER (hint));
+ error_at_rich_loc (&richloc,
+ "unknown type name %qE; did you mean %qE?",
+ c_parser_peek_token (parser)->value,
+ hint);
+ }
else
error_at (here, "unknown type name %qE",
c_parser_peek_token (parser)->value);
@@ -2370,6 +2370,9 @@ build_component_ref (location_t loc, tree datum, tree component,
field = lookup_field_fuzzy (type, component);
if (field)
{
+ richloc.add_fixit_replace
+ (*ident_range,
+ IDENTIFIER_POINTER (DECL_NAME (field)));
error_at_rich_loc
(&richloc,
"%qT has no member named %qE; did you mean %qE?",
@@ -15,6 +15,7 @@ int test (struct foo *ptr)
/* { dg-begin-multiline-output "" }
return ptr->m_bar;
~~~ ^~~~~
+ bar
{ dg-end-multiline-output "" } */
}
@@ -26,11 +27,14 @@ int test2 (void)
/* { dg-begin-multiline-output "" }
return instance.m_bar;
~~~~~~~~ ^~~~~
+ bar
{ dg-end-multiline-output "" } */
}
-int64 foo; /* { dg-error "unknown type name 'int64'; did you mean 'int'?" } */
+#include <inttypes.h>
+int64 foo; /* { dg-error "unknown type name 'int64'; did you mean 'int64_t'?" } */
/* { dg-begin-multiline-output "" }
int64 foo;
^~~~~
+ int64_t
{ dg-end-multiline-output "" } */