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++/96077] GCC accepts ill-legal local enum definition Date: Mon, 13 Jul 2020 15:16:57 +0000 [thread overview] Message-ID: <bug-96077-4-ytp4Xt9SRr@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-96077-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96077 --- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:4fd124a23664c712f1bb1a7e91fa23fe83d72c0b commit r11-2064-g4fd124a23664c712f1bb1a7e91fa23fe83d72c0b Author: Marek Polacek <polacek@redhat.com> Date: Thu Jul 9 20:44:05 2020 -0400 c++: Fix tentative parsing of enum-specifier [PR96077] Here's an interesting issue: in this code a ) is missing: enum { E = (2 } e; but we compile the code anyway, and E is set to 0 in build_enumerator, which is sneaky. The problem is that cp_parser_enum_specifier parses tentatively, because when we see the enum keyword, we don't know yet if we'll find an enum-specifier, opaque-enum-declaration, or elaborated-enum-specifier. In this test when we call cp_parser_enumerator_list we're still parsing tentatively, and as a consequence, parens.require_close (parser) in cp_parser_primary_expression doesn't report any errors. But we only go on to parse the enumerator-list after we've seen a {, at which point we might as well commit -- we know we're dealing with an enum-specifier. gcc/cp/ChangeLog: PR c++/96077 * parser.c (cp_parser_enum_specifier): Commit to tentative parse after we've seen an opening brace. gcc/testsuite/ChangeLog: PR c++/96077 * g++.dg/parse/enum14.C: New test.
next prev parent reply other threads:[~2020-07-13 15:16 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-06 12:31 [Bug c++/96077] New: " haoxintu at gmail dot com 2020-07-06 13:44 ` [Bug c++/96077] " redi at gcc dot gnu.org 2020-07-06 13:50 ` haoxintu at gmail dot com 2020-07-08 20:22 ` mpolacek at gcc dot gnu.org 2020-07-09 20:35 ` mpolacek at gcc dot gnu.org 2020-07-09 21:40 ` mpolacek at gcc dot gnu.org 2020-07-10 15:48 ` mpolacek at gcc dot gnu.org 2020-07-13 15:16 ` cvs-commit at gcc dot gnu.org [this message] 2020-07-13 15:19 ` cvs-commit at gcc dot gnu.org 2020-07-13 15:19 ` mpolacek at gcc dot gnu.org 2020-07-13 15:19 ` mpolacek 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-96077-4-ytp4Xt9SRr@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).