public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97202] GCC reports an error: expected unqualified-id before ‘short’ Date: Sat, 10 Feb 2024 13:38:42 +0000 [thread overview] Message-ID: <bug-97202-4-CegaI6kwVA@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-97202-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202 --- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:cff174fabd6c980c09aee95db1d9d5c22421761f commit r14-8915-gcff174fabd6c980c09aee95db1d9d5c22421761f Author: Marek Polacek <polacek@redhat.com> Date: Fri Feb 2 14:53:01 2024 -0500 c++: DR2237, cdtor and template-id tweaks [PR107126] Since my r11-532 changes to implement DR2237, for this test: template<typename T> struct S { S<T>(); }; in C++20 we emit the ugly: q.C:3:8: error: expected unqualified-id before ')' token 3 | S<T>(); which doesn't explain what the problem is. This patch improves that diagnostic, reduces the error to a pedwarn, and adds a -Wc++20-compat diagnostic. We now say: q.C:3:7: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor] 3 | S<T>(); q.C:3:7: note: remove the '< >' This patch also fixes <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202#c8> where the C++20 diagnostic was missing altogether: The problem was that I checked for CPP_TEMPLATE_ID too early, at a point at which cp_parser_template_id may not have been called yet. So let's check for it at the end of the function, after the tentative parse and rollback. -Wc++20-compat triggered in libitm/; I sent a patch for that. DR 2237 PR c++/107126 PR c++/97202 gcc/c-family/ChangeLog: * c-opts.cc (c_common_post_options): In C++20 or with -Wc++20-compat, turn on -Wtemplate-id-cdtor. * c.opt (Wtemplate-id-cdtor): New. gcc/cp/ChangeLog: * parser.cc (cp_parser_unqualified_id): Downgrade the DR2237 error to a pedwarn. (cp_parser_constructor_declarator_p): Likewise. gcc/ChangeLog: * doc/invoke.texi: Document -Wtemplate-id-cdtor. gcc/testsuite/ChangeLog: * g++.dg/DRs/dr2237.C: Adjust dg-error. * g++.dg/parse/constructor2.C: Likewise. * g++.dg/template/error34.C: Likewise. * g++.old-deja/g++.pt/ctor2.C: Likewise. * g++.dg/DRs/dr2237-2.C: New test. * g++.dg/DRs/dr2237-3.C: New test. * g++.dg/DRs/dr2237-4.C: New test. * g++.dg/DRs/dr2237-5.C: New test. * g++.dg/warn/Wtemplate-id-cdtor-1.C: New test. * g++.dg/warn/Wtemplate-id-cdtor-2.C: New test. * g++.dg/warn/Wtemplate-id-cdtor-3.C: New test. * g++.dg/warn/Wtemplate-id-cdtor-4.C: New test.
next prev parent reply other threads:[~2024-02-10 13:38 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-25 8:05 [Bug c++/97202] New: " tangyixuan at mail dot dlut.edu.cn 2020-09-25 8:27 ` [Bug c++/97202] [11 Regression] " rguenth at gcc dot gnu.org 2020-09-25 8:40 ` pinskia at gcc dot gnu.org 2020-09-25 13:16 ` mpolacek at gcc dot gnu.org 2020-09-25 13:20 ` [Bug c++/97202] " mpolacek at gcc dot gnu.org 2020-09-25 13:21 ` mpolacek at gcc dot gnu.org 2021-06-09 17:12 ` mpolacek at gcc dot gnu.org 2021-06-11 16:54 ` redi at gcc dot gnu.org 2021-06-11 16:58 ` redi at gcc dot gnu.org 2022-02-08 10:15 ` redi at gcc dot gnu.org 2022-02-08 10:17 ` redi at gcc dot gnu.org 2024-02-10 13:38 ` cvs-commit at gcc dot gnu.org [this message] 2024-02-10 13:43 ` mpolacek at gcc dot gnu.org 2024-04-21 21:38 ` pinskia at gcc dot gnu.org
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=bug-97202-4-CegaI6kwVA@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).