===================================================================
@@ -10797,13 +10797,14 @@ grokdeclarator (const cp_declarator *declarator,
else if (in_system_header_at (input_location) || flag_ms_extensions)
/* Allow it, sigh. */;
else if (! is_main)
- permerror (input_location, "ISO C++ forbids declaration of %qs with no type", name);
+ permerror (id_loc, "ISO C++ forbids declaration of %qs with no type",
+ name);
else if (pedantic)
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (id_loc, OPT_Wpedantic,
"ISO C++ forbids declaration of %qs with no type", name);
else
- warning (OPT_Wreturn_type,
- "ISO C++ forbids declaration of %qs with no type", name);
+ warning_at (id_loc, OPT_Wreturn_type,
+ "ISO C++ forbids declaration of %qs with no type", name);
if (type_was_error_mark_node && template_parm_flag)
/* FIXME we should be able to propagate the error_mark_node as is
@@ -11232,7 +11233,8 @@ grokdeclarator (const cp_declarator *declarator,
else if (toplevel_bindings_p ())
{
if (storage_class == sc_auto)
- error ("top-level declaration of %qs specifies %<auto%>", name);
+ error_at (declspecs->locations[ds_storage_class],
+ "top-level declaration of %qs specifies %<auto%>", name);
}
else if (thread_p
&& storage_class != sc_extern
@@ -12323,9 +12325,10 @@ grokdeclarator (const cp_declarator *declarator,
&& !(cxx_dialect >= cxx17 && template_parm_flag))
{
if (cxx_dialect >= cxx14)
- error ("%<auto%> parameter not permitted in this context");
+ error_at (typespec_loc,
+ "%<auto%> parameter not permitted in this context");
else
- error ("parameter declared %<auto%>");
+ error_at (typespec_loc, "parameter declared %<auto%>");
type = error_mark_node;
}
@@ -12746,9 +12749,12 @@ grokdeclarator (const cp_declarator *declarator,
// FIXME:gcc_assert (original_name == dname);
if (storage_class == sc_auto)
- error ("storage class %<auto%> invalid for function %qs", name);
+ error_at (declspecs->locations[ds_storage_class],
+ "storage class %<auto%> invalid for function %qs", name);
else if (storage_class == sc_register)
- error ("storage class %<register%> invalid for function %qs", name);
+ error_at (declspecs->locations[ds_storage_class],
+ "storage class %<register%> invalid for function %qs",
+ name);
else if (thread_p)
{
if (declspecs->gnu_thread_keyword_p)
===================================================================
@@ -78,10 +78,10 @@ enum struct D : auto * { FF = 0 }; // { dg-error
void
bar ()
{
- try { } catch (auto i) { } // { dg-error "parameter" }
- try { } catch (auto) { } // { dg-error "parameter" }
- try { } catch (auto *i) { } // { dg-error "parameter" }
- try { } catch (auto *) { } // { dg-error "parameter" }
+ try { } catch (auto i) { } // { dg-error "18:parameter" }
+ try { } catch (auto) { } // { dg-error "18:parameter" }
+ try { } catch (auto *i) { } // { dg-error "18:parameter" }
+ try { } catch (auto *) { } // { dg-error "18:parameter" }
}
void
@@ -111,7 +111,7 @@ badthrow2 () throw (auto &) // { dg-error "inval
{ // { dg-error "dynamic exception specification" "" { target c++17 } .-1 }
} // { dg-warning "deprecated" "" { target { ! c++17 } } .-2 }
-template <auto V = 4> struct G {}; // { dg-error "auto" "" { target { ! c++17 } } }
+template <auto V = 4> struct G {}; // { dg-error "11:parameter" "" { target { ! c++17 } } }
template <typename T> struct H { H (); ~H (); };
H<auto> h; // { dg-error "invalid|initializer" }
===================================================================
@@ -10,7 +10,7 @@
register int a __asm (REG1); // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
#endif
register int b; // { dg-error "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
-register int c (); // { dg-error "storage class 'register' invalid for function" }
+register int c (); // { dg-error "1:storage class 'register' invalid for function" }
int foo (register int d) // { dg-error "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
{
return d;
===================================================================
@@ -11,7 +11,7 @@
register int a __asm (REG1); // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
#endif
register int b; // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
-register int c (); // { dg-error "storage class 'register' invalid for function" }
+register int c (); // { dg-error "1:storage class 'register' invalid for function" }
int foo (register int d) // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
{
return d;
===================================================================
@@ -11,7 +11,7 @@
register int a __asm (REG1); // { dg-bogus "'register' storage class specifier used" }
#endif
register int b; // { dg-warning "'register' storage class specifier used" }
-register int c (); // { dg-error "storage class 'register' invalid for function" }
+register int c (); // { dg-error "1:storage class 'register' invalid for function" }
int foo (register int d) // { dg-warning "'register' storage class specifier used" }
{
return d;
===================================================================
@@ -0,0 +1,6 @@
+// { dg-do compile { target c++98_only } }
+
+void foo()
+{
+ auto void bar(); // { dg-error "3:storage class .auto. invalid for function" }
+}
===================================================================
@@ -0,0 +1 @@
+main() {} // { dg-error "1:ISO C\\+\\+ forbids declaration" }
===================================================================
@@ -0,0 +1,3 @@
+// { dg-options "-w" }
+
+foo() {} // { dg-error "1:ISO C\\+\\+ forbids declaration" }
===================================================================
@@ -0,0 +1,3 @@
+// { dg-do compile { target c++98_only } }
+
+auto int i; // { dg-error "1:top-level declaration of .i. specifies .auto." }
===================================================================
@@ -2,5 +2,5 @@
// { dg-do compile }
// { dg-options "" }
-S () : str(__PRETTY_FUNCTION__) { return S(); } // { dg-error "forbids declaration" "decl" }
+S () : str(__PRETTY_FUNCTION__) { return S(); } // { dg-error "1:ISO C\\+\\+ forbids declaration" "decl" }
// { dg-error "only constructors" "constructor" { target *-*-* } .-1 }