From: Jason Merrill <jason@redhat.com>
To: Marek Polacek <polacek@redhat.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c++: global-namespace-qualified var after class def [PR90107]
Date: Wed, 27 Apr 2022 20:51:08 -0400 [thread overview]
Message-ID: <baa72fea-a1a8-7fd5-ad42-2dcdebaa1dd1@redhat.com> (raw)
In-Reply-To: <20220427224526.1107353-1-polacek@redhat.com>
On 4/27/22 18:45, Marek Polacek wrote:
> 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.
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/11.4?
OK.
> 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.
> ---
> gcc/cp/parser.cc | 1 +
> gcc/testsuite/g++.dg/parse/qualified6.C | 10 ++++++++++
> 2 files changed, 11 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/parse/qualified6.C
>
> 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;
>
> base-commit: 58e4a744b6e8140499ed6c33a8e9a6557e102f74
prev parent reply other threads:[~2022-04-28 0:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 22:45 Marek Polacek
2022-04-28 0:51 ` Jason Merrill [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=baa72fea-a1a8-7fd5-ad42-2dcdebaa1dd1@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=polacek@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).