From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 65628388700B; Tue, 7 Apr 2020 19:03:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 65628388700B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586286205; bh=l99at6sk2HpZ46Imc9zEX0TqOpQAhxlmO0pej+FgTAg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vC4yaXR/US+84aV7lpa7VxmgT9fRTDftXLL/GOfhmu72Qs0r6OBVYpY3+veyNUd+W Tg8U4xt7Pxw2wxdhdpoO/+eE6UsM/YzlfPdH2KBMVHVHa37fAezFQTCbzYeWBN59DG zTE8gkY4fsrUO5n3AtQOeTfoCry2Ko2PFvIVwT3c= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/90995] [8/9 Regression] ICE in grokdeclarator, at cp/decl.c:12024 Date: Tue, 07 Apr 2020 19:03:25 +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: 10.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 8.5 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: Tue, 07 Apr 2020 19:03:25 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D90995 --- Comment #9 from CVS Commits --- The releases/gcc-9 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:980a7a0be5a114e285c49ab05ac70881e4f27fc3 commit r9-8462-g980a7a0be5a114e285c49ab05ac70881e4f27fc3 Author: Jakub Jelinek Date: Tue Mar 17 21:21:16 2020 +0100 c++: Fix parsing of invalid enum specifiers [PR90995] The testcase shows some accepts-invalid (the ones without alignas) and ice-on-invalid-code (the ones with alignas) cases. If the enum doesn't have an underlying type and is not a definition, the caller retries to parse it as elaborated type specifier. E.g. for enum struct S s it will then pedwarn that elaborated type specifier shouldn't have the struct/class keywords. The problem is if the enum specifier is not followed by { when it has underlying type. In that case we have already called cp_parser_parse_definitely to end the tentative parsing started at the beginning of cp_parser_enum_specifier. But the cp_parser_error (parser, "expected %<;%> or %<{%>"); doesn't emit any error because the whole function is called from yet another tentative parse and the caller starts parsing the elaborated type specifier where the cp_parser_enum_specifier stopped (i.e. after the underlying type token(s)). The ultimate caller than commits the tentat= ive parsing (and even if it wouldn't, it wouldn't know what kind of error to report). I think after seeing enum {,struct,class} : type not being followed by { or ;, there is no reason not to report it right away, as = it can't be valid C++, which is what the patch does. Not sure if we shoul= dn't also return error_mark_node instead of NULL_TREE, so that the caller doesn't try to parse it as elaborated type specifier (the patch doesn't do that right now). Furthermore, while reading the code, I've noticed that parser->colon_corrects_to_scope_p is saved and set to false at the start of the function, but not restored back in some cases. Don't have a testcase where this would be a problem, but it just seems wrong. Either we can = in the two spots replace return NULL_TREE; with { type =3D NULL_TREE; goto= out; } or we could perhaps abuse warning_sentinel or create a special class wi= th dtor to clean the flag up. And lastly, I've fixed some formatting issues in the function while rea= ding it. 2020-03-17 Jakub Jelinek PR c++/90995 * parser.c (cp_parser_enum_specifier): Use temp_override for parser->colon_corrects_to_scope_p, replace goto out with return. If scoped enum or enum with underlying type is not followed by { or ;, call cp_parser_commit_to_tentative_parse before calling cp_parser_error and make sure to return error_mark_node instead= of NULL_TREE. Formatting fixes. * g++.dg/cpp0x/enum40.C: New test.=