diff mbox series

[C++] One more location fix

Message ID 379075c8-4a86-4a5b-653b-bd82dde26666@oracle.com
State New
Headers show
Series [C++] One more location fix | expand

Commit Message

Paolo Carlini May 8, 2019, 9:02 a.m. UTC
Hi again,

one more straightforward fixlet which remained in my tree for a while. 
Tested x86_64-linux.

Thanks, Paolo.

/////////////////
/cp
2019-04-29  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (grokvardecl): Use an accurate location in error message
	about main as a global variable.

/testsuite
2019-04-29  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/diagnostic/main1.C: New.

Comments

Jason Merrill May 10, 2019, 2:46 p.m. UTC | #1
On 5/8/19 5:02 AM, Paolo Carlini wrote:
> Hi again,
> 
> one more straightforward fixlet which remained in my tree for a while. 
> Tested x86_64-linux.
> 
> Thanks, Paolo.
> 
> /////////////////
> 

OK.

Jason
diff mbox series

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 270643)
+++ cp/decl.c	(working copy)
@@ -9475,7 +9475,8 @@  grokvardecl (tree type,
   if (DECL_NAME (decl)
       && MAIN_NAME_P (DECL_NAME (decl))
       && scope == global_namespace)
-    error ("cannot declare %<::main%> to be a global variable");
+    error_at (DECL_SOURCE_LOCATION (decl),
+	      "cannot declare %<::main%> to be a global variable");
 
   /* Check that the variable can be safely declared as a concept.
      Note that this also forbids explicit specializations.  */
Index: testsuite/g++.dg/diagnostic/main1.C
===================================================================
--- testsuite/g++.dg/diagnostic/main1.C	(nonexistent)
+++ testsuite/g++.dg/diagnostic/main1.C	(working copy)
@@ -0,0 +1 @@ 
+int main __attribute__((unused));  // { dg-error "5:cannot declare" }