]> git.ipfire.org Git - thirdparty/gcc.git/commit
libcpp: Fix up ##__VA_OPT__ handling [PR89971]
authorJakub Jelinek <jakub@redhat.com>
Thu, 30 Dec 2021 21:23:58 +0000 (22:23 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 11 May 2022 05:58:35 +0000 (07:58 +0200)
commit86b98701bf927ea438354723932e623557c04e42
treec151eef93046b62478c7f869f110fe9613579f45
parent5d96fb401e1c03b6b6a6ec2c5276dfdc479bb3e4
libcpp: Fix up ##__VA_OPT__ handling [PR89971]

In the following testcase we incorrectly error about pasting / token
with padding token (which is a result of __VA_OPT__); instead we should
like e.g. for ##arg where arg is empty macro argument clear PASTE_LEFT
flag of the previous token if __VA_OPT__ doesn't add any real tokens
(which can happen either because the macro doesn't have any tokens
passed to ... (i.e. __VA_ARGS__ expands to empty) or when __VA_OPT__
doesn't have any tokens in between ()s).

2021-12-30  Jakub Jelinek  <jakub@redhat.com>

PR preprocessor/89971
libcpp/
* macro.c (replace_args): For ##__VA_OPT__, if __VA_OPT__ expands
to no tokens at all, drop PASTE_LEFT flag from the previous token.
gcc/testsuite/
* c-c++-common/cpp/va-opt-9.c: New test.

(cherry picked from commit 5545d1edcbdb1701443f94dde7ec97c5ce3e1a6c)
gcc/testsuite/c-c++-common/cpp/va-opt-9.c [new file with mode: 0644]
libcpp/macro.c