+2019-06-22 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * decl.c (grokdeclarator): Use id_loc, typespec_loc, and
+ locations[ds_storage_class] in a few additional places.
+
2019-06-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/90909
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
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
&& !(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;
}
// 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)
+2019-06-22 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/diagnostic/auto-storage-1.C: New.
+ * g++.dg/diagnostic/no-type-1.C: Likewise.
+ * g++.dg/diagnostic/no-type-2.C: Likewise.
+ * g++.dg/diagnostic/top-level-auto-1.C: Likewise.
+ * g++.dg/cpp0x/auto9.C: Test some locations too.
+ * g++.dg/cpp1z/register1.C: Likewise.
+ * g++.dg/cpp1z/register2.C: Likewise.
+ * g++.dg/cpp1z/register3.C: Likewise.
+ * g++.dg/other/error34.C: Likewise.
+
2019-06-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/90909
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
{ // { 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" }
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;
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;
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;
--- /dev/null
+// { dg-do compile { target c++98_only } }
+
+void foo()
+{
+ auto void bar(); // { dg-error "3:storage class .auto. invalid for function" }
+}
--- /dev/null
+main() {} // { dg-error "1:ISO C\\+\\+ forbids declaration" }
--- /dev/null
+// { dg-options "-w" }
+
+foo() {} // { dg-error "1:ISO C\\+\\+ forbids declaration" }
--- /dev/null
+// { dg-do compile { target c++98_only } }
+
+auto int i; // { dg-error "1:top-level declaration of .i. specifies .auto." }
// { 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 }