diff options
author | Paolo Carlini <paolo@gcc.gnu.org> | 2015-08-20 10:18:03 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2015-08-20 10:18:03 +0000 |
commit | dfd71aba57811c28d21a49909d9c6b96f5ae05ea (patch) | |
tree | 3c00edc44d1918711586f8f1529d6b2d37f4c7bf /gcc/cp | |
parent | 58df0b91cbca6814b243256bb7900341b5316d14 (diff) | |
download | gcc-dfd71aba57811c28d21a49909d9c6b96f5ae05ea.zip gcc-dfd71aba57811c28d21a49909d9c6b96f5ae05ea.tar.gz gcc-dfd71aba57811c28d21a49909d9c6b96f5ae05ea.tar.bz2 |
re PR c++/67065 ([DR 1886] Missing diagnostics for ill-formed program with main variable instead of function)
/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.
From-SVN: r227027
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2a083c8..53d4feb 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 5c75972..4f77e7c 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) |