From: Marek Polacek Date: Wed, 27 Apr 2022 22:17:54 +0000 (-0400) Subject: c++: global-namespace-qualified var after class def [PR90107] X-Git-Tag: upstream/12.2.0~393 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=851031b2fcd5210b96769c440db10130478d273c;p=platform%2Fupstream%2Fgcc.git c++: global-namespace-qualified var after class def [PR90107] Here we wrongly reject the definition of "::N::a" struct A; namespace N { extern A a; } struct A {} ::N::a; because our code to diagnose a missing ; after a class definition doesn't realize that :: can follow a class definition. PR c++/90107 gcc/cp/ChangeLog: * parser.cc (cp_parser_class_specifier_1): Accept :: after a class definition. gcc/testsuite/ChangeLog: * g++.dg/parse/qualified6.C: New test. --- diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 169e6a6..2235da1 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -25933,6 +25933,7 @@ cp_parser_class_specifier_1 (cp_parser* parser) case CPP_OPEN_PAREN: case CPP_CLOSE_PAREN: case CPP_COMMA: + case CPP_SCOPE: want_semicolon = false; break; diff --git a/gcc/testsuite/g++.dg/parse/qualified6.C b/gcc/testsuite/g++.dg/parse/qualified6.C new file mode 100644 index 0000000..68b51f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/qualified6.C @@ -0,0 +1,10 @@ +// PR c++/90107 +// { dg-do compile } + +struct A; +namespace N { extern A a; } +struct A {} ::N::a; + +struct A1; +struct B { static A1 a1; }; +struct A1 {} ::B::a1;