public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] More grokdeclarator locations
@ 2019-06-14  0:12 Paolo Carlini
  2019-06-22  4:18 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2019-06-14  0:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

Hi,

should all be rather straightforward but I spent quite a bit of time on 
the testsuite changes... Tested x86_64-linux, as usual.

Thanks, Paolo.

PS: at some point we should start talking about all the error, error_at, 
etc, which are *never* exercised by our testsuite. I'm coming to the 
conclusion that some should really go. Any general procedural suggestions?

///////////////////



[-- Attachment #2: CL_locs_36 --]
[-- Type: text/plain, Size: 628 bytes --]

/cp
2019-06-14  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-14  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.

[-- Attachment #3: patch_locs_36 --]
[-- Type: text/plain, Size: 8179 bytes --]

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 272259)
+++ cp/decl.c	(working copy)
@@ -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)
Index: testsuite/g++.dg/cpp0x/auto9.C
===================================================================
--- testsuite/g++.dg/cpp0x/auto9.C	(revision 272259)
+++ testsuite/g++.dg/cpp0x/auto9.C	(working copy)
@@ -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" }
Index: testsuite/g++.dg/cpp1z/register1.C
===================================================================
--- testsuite/g++.dg/cpp1z/register1.C	(revision 272259)
+++ testsuite/g++.dg/cpp1z/register1.C	(working copy)
@@ -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;
Index: testsuite/g++.dg/cpp1z/register2.C
===================================================================
--- testsuite/g++.dg/cpp1z/register2.C	(revision 272259)
+++ testsuite/g++.dg/cpp1z/register2.C	(working copy)
@@ -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;
Index: testsuite/g++.dg/cpp1z/register3.C
===================================================================
--- testsuite/g++.dg/cpp1z/register3.C	(revision 272259)
+++ testsuite/g++.dg/cpp1z/register3.C	(working copy)
@@ -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;
Index: testsuite/g++.dg/diagnostic/auto-storage-1.C
===================================================================
--- testsuite/g++.dg/diagnostic/auto-storage-1.C	(nonexistent)
+++ testsuite/g++.dg/diagnostic/auto-storage-1.C	(working copy)
@@ -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" }
+}
Index: testsuite/g++.dg/diagnostic/no-type-1.C
===================================================================
--- testsuite/g++.dg/diagnostic/no-type-1.C	(nonexistent)
+++ testsuite/g++.dg/diagnostic/no-type-1.C	(working copy)
@@ -0,0 +1 @@
+main() {}  // { dg-error "1:ISO C\\+\\+ forbids declaration" }
Index: testsuite/g++.dg/diagnostic/no-type-2.C
===================================================================
--- testsuite/g++.dg/diagnostic/no-type-2.C	(nonexistent)
+++ testsuite/g++.dg/diagnostic/no-type-2.C	(working copy)
@@ -0,0 +1,3 @@
+// { dg-options "-w" }
+
+foo() {}  // { dg-error "1:ISO C\\+\\+ forbids declaration" }
Index: testsuite/g++.dg/diagnostic/top-level-auto-1.C
===================================================================
--- testsuite/g++.dg/diagnostic/top-level-auto-1.C	(nonexistent)
+++ testsuite/g++.dg/diagnostic/top-level-auto-1.C	(working copy)
@@ -0,0 +1,3 @@
+// { dg-do compile { target c++98_only } }
+
+auto int i;  // { dg-error "1:top-level declaration of .i. specifies .auto." }
Index: testsuite/g++.dg/other/error34.C
===================================================================
--- testsuite/g++.dg/other/error34.C	(revision 272259)
+++ testsuite/g++.dg/other/error34.C	(working copy)
@@ -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 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ Patch] More grokdeclarator locations
  2019-06-14  0:12 [C++ Patch] More grokdeclarator locations Paolo Carlini
@ 2019-06-22  4:18 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2019-06-22  4:18 UTC (permalink / raw)
  To: Paolo Carlini, gcc-patches

On 6/13/19 8:12 PM, Paolo Carlini wrote:
> Hi,
> 
> should all be rather straightforward but I spent quite a bit of time on 
> the testsuite changes... Tested x86_64-linux, as usual.

OK.

> PS: at some point we should start talking about all the error, error_at, 
> etc, which are *never* exercised by our testsuite. I'm coming to the 
> conclusion that some should really go. Any general procedural suggestions?

It could certainly be useful to get a sense of our test coverage.  It 
does seem a bit odd that we don't have a target for running the 
testsuite under gcov.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-22  4:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14  0:12 [C++ Patch] More grokdeclarator locations Paolo Carlini
2019-06-22  4:18 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).