From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id B1A623858C60; Mon, 24 Jan 2022 09:20:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1A623858C60 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9490] c: Fix ICE on deferred pragma in unknown attribute arguments [PR103587] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 520147ba19db8034b1f911326beee104da606daa X-Git-Newrev: c239267759be2cf3e1afadea86aff5ba3517d934 Message-Id: <20220124092025.B1A623858C60@sourceware.org> Date: Mon, 24 Jan 2022 09:20:25 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jan 2022 09:20:25 -0000 https://gcc.gnu.org/g:c239267759be2cf3e1afadea86aff5ba3517d934 commit r11-9490-gc239267759be2cf3e1afadea86aff5ba3517d934 Author: Jakub Jelinek Date: Tue Dec 14 12:02:55 2021 +0100 c: Fix ICE on deferred pragma in unknown attribute arguments [PR103587] We ICE on the following testcase, because c_parser_balanced_token_sequence when encountering a deferred pragma will just use c_parser_consume_token which the FE doesn't allow for CPP_PRAGMA tokens (and if that wasn't the case, it could ICE on CPP_PRAGMA_EOL similarly). We don't know in what exact context the pragma appears when we don't know what those arguments semantically mean, so I think we should just skip over them, like e.g. the C++ FE does. And, I think (/[/{ vs. )/]/} from outside of the pragma shouldn't be paired with those inside of the pragma and it doesn't seem to be necessary to check that inside of the pragma line itself all the paren kinds are balanced. 2021-12-14 Jakub Jelinek PR c/103587 * c-parser.c (c_parser_balanced_token_sequence): For CPP_PRAGMA, consume the pragma and silently skip to the pragma eol. * gcc.dg/pr103587.c: New test. (cherry picked from commit e163dbbc4433e598cad7e6011b255d1d6ad93a3b) Diff: --- gcc/c/c-parser.c | 5 +++++ gcc/testsuite/gcc.dg/pr103587.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 8897e4348a2..7690977f6b8 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -4841,6 +4841,11 @@ c_parser_balanced_token_sequence (c_parser *parser) case CPP_EOF: return; + case CPP_PRAGMA: + c_parser_consume_pragma (parser); + c_parser_skip_to_pragma_eol (parser, false); + break; + default: c_parser_consume_token (parser); break; diff --git a/gcc/testsuite/gcc.dg/pr103587.c b/gcc/testsuite/gcc.dg/pr103587.c new file mode 100644 index 00000000000..1cbc4d52d9d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr103587.c @@ -0,0 +1,7 @@ +/* PR c/103587 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +[[foo::bar( +#pragma GCC ivdep +)]]; /* { dg-warning "attribute ignored" } */