aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-20 10:18:03 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-20 10:18:03 +0000
commitddcdcdb752c1accf90fc11880206ca268d2f038a (patch)
tree3c00edc44d1918711586f8f1529d6b2d37f4c7bf
parent1731ea5816a05ba969926868f3ffe733d2d4bdbd (diff)
/cp
2015-08-20 Paolo Carlini <paolo.carlini@oracle.com> PR c++/67065 * decl.c (grokvardecl): Reject 'main' as global variable. /testsuite 2015-08-20 Paolo Carlini <paolo.carlini@oracle.com> PR c++/67065 * g++.dg/other/pr67065.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227027 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c5
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/other/pr67065.C3
4 files changed, 20 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2a083c804d2..53d4febe962 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2015-08-20 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/67065
+ * decl.c (grokvardecl): Reject 'main' as global variable.
+
2015-08-19 Jason Merrill <jason@redhat.com>
PR c++/66957
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5c75972136a..4f77e7c23c4 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8355,6 +8355,11 @@ grokvardecl (tree type,
else
DECL_INTERFACE_KNOWN (decl) = 1;
+ if (DECL_NAME (decl)
+ && MAIN_NAME_P (DECL_NAME (decl))
+ && CP_DECL_CONTEXT (decl) == global_namespace)
+ error ("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. */
if (conceptp)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index be331444423..36a3d9e2716 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,12 @@
+2015-08-20 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/67065
+ * g++.dg/other/pr67065.C: New.
+
2015-08-20 Simon Dardis <simon.dardis@imgtec.com>
- * gcc.target/mips/inline-memcpy-1.c: Test for inline expansion of memcpy.
+ * gcc.target/mips/inline-memcpy-1.c: Test for inline expansion of
+ memcpy.
* gcc.target/mips/inline-memcpy-2.c: Ditto.
* gcc.target/mips/inline-memcpy-3.c: Ditto.
* gcc.target/mips/inline-memcpy-4.c: Ditto.
diff --git a/gcc/testsuite/g++.dg/other/pr67065.C b/gcc/testsuite/g++.dg/other/pr67065.C
new file mode 100644
index 00000000000..cbf03b23b8a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/pr67065.C
@@ -0,0 +1,3 @@
+// PR c++/67065
+
+int main; // { dg-error "cannot declare" }