===================================================================
@@ -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. */
===================================================================
@@ -0,0 +1 @@
+int main __attribute__((unused)); // { dg-error "5:cannot declare" }