From: Paolo Carlini Date: Fri, 21 Aug 2015 14:44:33 +0000 (+0000) Subject: decl.c (grokvardecl): Complete check added for c++/67065. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cf6a9610f2e86f6de12281cc47b2d5a5acba63e4;p=gcc.git decl.c (grokvardecl): Complete check added for c++/67065. /cp 2015-08-21 Paolo Carlini * decl.c (grokvardecl): Complete check added for c++/67065. /testsuite 2015-08-21 Paolo Carlini * g++.dg/other/pr67065.C: Extend. From-SVN: r227061 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 245cf11df78..f8fae34b760 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2015-08-21 Paolo Carlini + + * decl.c (grokvardecl): Complete check added for c++/67065. + 2015-08-20 Jason Merrill * name-lookup.c (hidden_name_p): Handle OVERLOAD. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 4f77e7c23c4..ab55e75f27e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 95c82570ba5..08d7118be68 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-08-21 Paolo Carlini + + * g++.dg/other/pr67065.C: Extend. + 2015-08-21 Nathan Sidwell * lib/target-supports.exp (check_effective_target_freestanding): nvptx diff --git a/gcc/testsuite/g++.dg/other/pr67065.C b/gcc/testsuite/g++.dg/other/pr67065.C index cbf03b23b8a..790bde414df 100644 --- a/gcc/testsuite/g++.dg/other/pr67065.C +++ b/gcc/testsuite/g++.dg/other/pr67065.C @@ -1,3 +1,5 @@ // PR c++/67065 int main; // { dg-error "cannot declare" } + +void foo() { int main; }