decl.c (grokvardecl): Complete check added for c++/67065.
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 21 Aug 2015 14:44:33 +0000 (14:44 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 21 Aug 2015 14:44:33 +0000 (14:44 +0000)
/cp
2015-08-21  Paolo Carlini  <paolo.carlini@oracle.com>

* decl.c (grokvardecl): Complete check added for c++/67065.

/testsuite
2015-08-21  Paolo Carlini  <paolo.carlini@oracle.com>

* g++.dg/other/pr67065.C: Extend.

From-SVN: r227061

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr67065.C

index 245cf11df7810f35596c378d5e6963502ccb3ccb..f8fae34b760adbc4dae0e254915286b684359760 100644 (file)
@@ -1,3 +1,7 @@
+2015-08-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * decl.c (grokvardecl): Complete check added for c++/67065.
+
 2015-08-20  Jason Merrill  <jason@redhat.com>
 
        * name-lookup.c (hidden_name_p): Handle OVERLOAD.
index 4f77e7c23c42a028813ea1f32a137a36fe4f797a..ab55e75f27eab465a0270e4c24cc4870d3b4f8d3 100644 (file)
@@ -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 95c82570ba59294a4413b93639377d5fb663bab5..08d7118be681e0c1146e05831b300fd3fe1d4078 100644 (file)
@@ -1,3 +1,7 @@
+2015-08-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * g++.dg/other/pr67065.C: Extend.
+
 2015-08-21  Nathan Sidwell  <nathan@acm.org>
 
        * lib/target-supports.exp (check_effective_target_freestanding): nvptx
index cbf03b23b8a962067fd29d3ee89e0b25e42f463c..790bde414dfd139b72eeb24a781311bf044f6633 100644 (file)
@@ -1,3 +1,5 @@
 // PR c++/67065
 
 int main;  // { dg-error "cannot declare" }
+
+void foo() { int main; }