public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8304] c++: global-namespace-qualified var after class def [PR90107]
@ 2022-04-28 12:41 Marek Polacek
  0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2022-04-28 12:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:851031b2fcd5210b96769c440db10130478d273c

commit r12-8304-g851031b2fcd5210b96769c440db10130478d273c
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Apr 27 18:17:54 2022 -0400

    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:
---
 gcc/cp/parser.cc                        |  1 +
 gcc/testsuite/g++.dg/parse/qualified6.C | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 169e6a62f5f..2235da10c7c 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 00000000000..68b51f771ec
--- /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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-28 12:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 12:41 [gcc r12-8304] c++: global-namespace-qualified var after class def [PR90107] Marek Polacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).