]> gcc.gnu.org Git - gcc.git/commit
c: Fix ICE on deferred pragma in unknown attribute arguments [PR103587]
authorJakub Jelinek <jakub@redhat.com>
Tue, 14 Dec 2021 11:02:55 +0000 (12:02 +0100)
committerJakub Jelinek <jakub@redhat.com>
Mon, 24 Jan 2022 09:19:55 +0000 (10:19 +0100)
commitc239267759be2cf3e1afadea86aff5ba3517d934
tree7fe003fdebdf405819b1ba1ae5ff592a4c251934
parent520147ba19db8034b1f911326beee104da606daa
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  <jakub@redhat.com>

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)
gcc/c/c-parser.c
gcc/testsuite/gcc.dg/pr103587.c [new file with mode: 0644]
This page took 0.065449 seconds and 6 git commands to generate.