Commit 4b3aa535 by Paolo Carlini Committed by Paolo Carlini

decl.c (grokdeclarator): Use id_loc...

/cp
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.

/testsuite
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.

From-SVN: r272584
parent bd5cb8ed
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> 2019-06-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/90909 PR c++/90909
......
...@@ -10816,12 +10816,13 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -10816,12 +10816,13 @@ grokdeclarator (const cp_declarator *declarator,
else if (in_system_header_at (input_location) || flag_ms_extensions) else if (in_system_header_at (input_location) || flag_ms_extensions)
/* Allow it, sigh. */; /* Allow it, sigh. */;
else if (! is_main) 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) else if (pedantic)
pedwarn (input_location, OPT_Wpedantic, pedwarn (id_loc, OPT_Wpedantic,
"ISO C++ forbids declaration of %qs with no type", name); "ISO C++ forbids declaration of %qs with no type", name);
else else
warning (OPT_Wreturn_type, warning_at (id_loc, OPT_Wreturn_type,
"ISO C++ forbids declaration of %qs with no type", name); "ISO C++ forbids declaration of %qs with no type", name);
if (type_was_error_mark_node && template_parm_flag) if (type_was_error_mark_node && template_parm_flag)
...@@ -11251,7 +11252,8 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -11251,7 +11252,8 @@ grokdeclarator (const cp_declarator *declarator,
else if (toplevel_bindings_p ()) else if (toplevel_bindings_p ())
{ {
if (storage_class == sc_auto) 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 else if (thread_p
&& storage_class != sc_extern && storage_class != sc_extern
...@@ -12358,9 +12360,10 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12358,9 +12360,10 @@ grokdeclarator (const cp_declarator *declarator,
&& !(cxx_dialect >= cxx17 && template_parm_flag)) && !(cxx_dialect >= cxx17 && template_parm_flag))
{ {
if (cxx_dialect >= cxx14) if (cxx_dialect >= cxx14)
error ("%<auto%> parameter not permitted in this context"); error_at (typespec_loc,
"%<auto%> parameter not permitted in this context");
else else
error ("parameter declared %<auto%>"); error_at (typespec_loc, "parameter declared %<auto%>");
type = error_mark_node; type = error_mark_node;
} }
...@@ -12781,9 +12784,12 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12781,9 +12784,12 @@ grokdeclarator (const cp_declarator *declarator,
// FIXME:gcc_assert (original_name == dname); // FIXME:gcc_assert (original_name == dname);
if (storage_class == sc_auto) 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) 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) else if (thread_p)
{ {
if (declspecs->gnu_thread_keyword_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> 2019-06-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/90909 PR c++/90909
......
...@@ -78,10 +78,10 @@ enum struct D : auto * { FF = 0 }; // { dg-error "must be an integral type|decl ...@@ -78,10 +78,10 @@ enum struct D : auto * { FF = 0 }; // { dg-error "must be an integral type|decl
void void
bar () bar ()
{ {
try { } catch (auto i) { } // { dg-error "parameter" } try { } catch (auto i) { } // { dg-error "18:parameter" }
try { } catch (auto) { } // { dg-error "parameter" } try { } catch (auto) { } // { dg-error "18:parameter" }
try { } catch (auto *i) { } // { dg-error "parameter" } try { } catch (auto *i) { } // { dg-error "18:parameter" }
try { } catch (auto *) { } // { dg-error "parameter" } try { } catch (auto *) { } // { dg-error "18:parameter" }
} }
void void
...@@ -111,7 +111,7 @@ badthrow2 () throw (auto &) // { dg-error "invalid use of|expected" } ...@@ -111,7 +111,7 @@ badthrow2 () throw (auto &) // { dg-error "invalid use of|expected" }
{ // { dg-error "dynamic exception specification" "" { target c++17 } .-1 } { // { dg-error "dynamic exception specification" "" { target c++17 } .-1 }
} // { dg-warning "deprecated" "" { target { ! c++17 } } .-2 } } // { 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 (); }; template <typename T> struct H { H (); ~H (); };
H<auto> h; // { dg-error "invalid|initializer" } H<auto> h; // { dg-error "invalid|initializer" }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
register int a __asm (REG1); // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } register int a __asm (REG1); // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
#endif #endif
register int b; // { dg-error "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } 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 } } int foo (register int d) // { dg-error "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
{ {
return d; return d;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
register int a __asm (REG1); // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } register int a __asm (REG1); // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
#endif #endif
register int b; // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } } 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 } } int foo (register int d) // { dg-bogus "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } }
{ {
return d; return d;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
register int a __asm (REG1); // { dg-bogus "'register' storage class specifier used" } register int a __asm (REG1); // { dg-bogus "'register' storage class specifier used" }
#endif #endif
register int b; // { dg-warning "'register' storage class specifier used" } 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" } int foo (register int d) // { dg-warning "'register' storage class specifier used" }
{ {
return d; return d;
......
// { dg-do compile { target c++98_only } }
void foo()
{
auto void bar(); // { dg-error "3:storage class .auto. invalid for function" }
}
main() {} // { dg-error "1:ISO C\\+\\+ forbids declaration" }
// { dg-options "-w" }
foo() {} // { dg-error "1:ISO C\\+\\+ forbids declaration" }
// { dg-do compile { target c++98_only } }
auto int i; // { dg-error "1:top-level declaration of .i. specifies .auto." }
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// { dg-do compile } // { dg-do compile }
// { dg-options "" } // { 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 } // { dg-error "only constructors" "constructor" { target *-*-* } .-1 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment