public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9392] c++: Don't try to parse a function declaration as deduction guide [PR97663] Date: Tue, 20 Apr 2021 23:30:00 +0000 (GMT) [thread overview] Message-ID: <20210420233000.C9E27388A837@sourceware.org> (raw) https://gcc.gnu.org/g:c3a583316776a399fea9eb79019245138a2be181 commit r9-9392-gc3a583316776a399fea9eb79019245138a2be181 Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Nov 3 21:42:51 2020 +0100 c++: Don't try to parse a function declaration as deduction guide [PR97663] While these function declarations have NULL decl_specifiers->type, they have still type specifiers specified from which the default int in the return type is added, so we shouldn't try to parse those as deduction guides. 2020-11-03 Jakub Jelinek <jakub@redhat.com> PR c++/97663 * parser.c (cp_parser_init_declarator): Don't try to parse C++17 deduction guides if there are any type specifiers even when type is NULL. * g++.dg/cpp1z/class-deduction75.C: New test. (cherry picked from commit cd41e4a1864c10c7f9141284e82e5cc0a3007806) Diff: --- gcc/cp/parser.c | 1 + gcc/testsuite/g++.dg/cpp1z/class-deduction75.C | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 58274a3a8c3..64dde058dd3 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -20269,6 +20269,7 @@ cp_parser_init_declarator (cp_parser* parser, { /* Handle C++17 deduction guides. */ if (!decl_specifiers->type + && !decl_specifiers->any_type_specifiers_p && ctor_dtor_or_conv_p <= 0 && cxx_dialect >= cxx17) { diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction75.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction75.C new file mode 100644 index 00000000000..52e6131c7b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction75.C @@ -0,0 +1,15 @@ +// PR c++/97663 + +template <class T> struct foo {}; +template <class T> struct bar {}; +template <class T> struct baz {}; +template <class T> struct qux {}; +template <class T> struct corge {}; + +namespace N { + unsigned foo (); + signed bar (); + long baz (); + long long qux (); + short corge (); +}
reply other threads:[~2021-04-20 23:30 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210420233000.C9E27388A837@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).