From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 827B738930F5; Mon, 13 Jul 2020 15:16:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 827B738930F5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594653417; bh=GJcRIcj03JAM4tKI73StKkohAhOVJhRa1i94ctYx/lc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BDdNi/ne/DiE6j/+iuETcmfwEfT62boz8i3PtqHlLG/V0qVBuylI7UUxxCbvXSKuo JdgU3JlbCh+EZYqw7mA0cCNHc5RkwFIqKAgfyhCopDgAbMhBnnz/aPAJ99BuoxK2Nj V5GjQMjxf0ZtkuOx7dY9dAi4L18Mn70wNPJOlCPo= From: "cvs-commit at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: accepts-invalid, patch X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jul 2020 15:16:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96077 --- Comment #7 from CVS Commits --- The master branch has been updated by Marek Polacek : https://gcc.gnu.org/g:4fd124a23664c712f1bb1a7e91fa23fe83d72c0b commit r11-2064-g4fd124a23664c712f1bb1a7e91fa23fe83d72c0b Author: Marek Polacek 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 =3D (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.=