From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4C7613858036; Tue, 15 Mar 2022 08:16:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C7613858036 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104623] [11/12 Regression] ICE in cp_parser_skip_to_pragma_eol, at cp/parser.cc:4107 Date: Tue, 15 Mar 2022 08:15:59 +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: 12.0 X-Bugzilla-Keywords: ice-on-invalid-code, openmp 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: 11.3 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, 15 Mar 2022 08:16:00 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104623 --- Comment #4 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:efd1582926f3278a5e57ebab7d87fc870f06ecea commit r12-7652-gefd1582926f3278a5e57ebab7d87fc870f06ecea Author: Jakub Jelinek Date: Tue Mar 15 09:15:27 2022 +0100 c++: Fix up cp_parser_skip_to_pragma_eol [PR104623] We ICE on the following testcase, because we tentatively parse it multi= ple times and the erroneous attribute syntax results in cp_parser_skip_to_end_of_statement, which when seeing CPP_PRAGMA (can be any deferred one, OpenMP/OpenACC/ivdep etc.) it calls cp_parser_skip_to_pragma_eol, which calls cp_lexer_purge_tokens_after. That call purges all the tokens from CPP_PRAGMA until CPP_PRAGMA_EOL, excluding the initial CPP_PRAGMA though (but including the final CPP_PRAGMA_EOL). This means the second time we parse this, we see CPP_PRAGMA with no tokens after it from the pragma, most importantly not the CPP_PRAGMA_EOL, so either if it is the last pragma in the TU, we ICE, or if there are other pragmas we treat everything in between as a pragma. I've tried various things, including making the CPP_PRAGMA token itself also purged, or changing the cp_parser_skip_to_end_of_statement (and cp_parser_skip_to_end_of_block_or_statement) to call it with NULL instead of token, so that this purging isn't done there, but each patch resulted in lots of regressions. But removing the purging altogether surprisingly doesn't regress anythi= ng, and I think it is the right thing, if we e.g. parse tentatively, why ca= n't we parse the pragma multiple times or at least skip over it? 2022-03-15 Jakub Jelinek PR c++/104623 * parser.cc (cp_parser_skip_to_pragma_eol): Don't purge any tok= ens. * g++.dg/gomp/pr104623.C: New test.=