... I'm testing the below. So far appears to work well for me.

Paolo.

///////////////////
Index: cp/decl.c
===================================================================
--- cp/decl.c   (revision 227054)
+++ cp/decl.c   (working copy)
@@ -8357,7 +8357,8 @@ grokvardecl (tree type,
 
   if (DECL_NAME (decl)
       && MAIN_NAME_P (DECL_NAME (decl))
-      && CP_DECL_CONTEXT (decl) == global_namespace)
+      && CP_DECL_CONTEXT (decl) == global_namespace
+      && !at_function_scope_p ())
     error ("cannot declare %<::main%> to be a global variable");
 
   /* Check that the variable can be safely declared as a concept.
Index: testsuite/g++.dg/other/pr67065.C
===================================================================
--- testsuite/g++.dg/other/pr67065.C    (revision 227054)
+++ testsuite/g++.dg/other/pr67065.C    (working copy)
@@ -1,3 +1,5 @@
 // PR c++/67065
 
 int main;  // { dg-error "cannot declare" }
+
+void foo() { int main; }

Reply via email to