From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ABBB8385BF9D; Wed, 1 Sep 2021 19:34:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABBB8385BF9D From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/101488] Implement p1042r1 __VA_OPT__ placemarker changes Date: Wed, 01 Sep 2021 19:34:55 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: Wed, 01 Sep 2021 19:34:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101488 --- Comment #4 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:e928cf47f350e46eacb48ed954112e603ef3800a commit r12-3298-ge928cf47f350e46eacb48ed954112e603ef3800a Author: Jakub Jelinek Date: Wed Sep 1 21:31:25 2021 +0200 libcpp: __VA_OPT__ p1042r1 placemarker changes [PR101488] So, besides missing #__VA_OPT__ patch for which I've posted patch last week, P1042R1 introduced some placemarker changes for __VA_OPT__, most notably the addition of before "removal of placemarker tokens," rescanning ... and the #define H4(X, ...) __VA_OPT__(a X ## X) ## b H4(, 1) // replaced by a b example mentioned there where we replace it currently with ab The following patch are the minimum changes (except for the __builtin_expect) that achieve the same preprocessing between current clang++ and patched gcc on all the testcases I've tried (i.e. gcc __VA_OPT__ testsuite in c-c++-common/cpp/va-opt* including the new test and the cl= ang clang/test/Preprocessor/macro_va_opt* testcases). At one point I was trying to implement the __VA_OPT__(args) case as if for non-empty __VA_ARGS__ it expanded as if __VA_OPT__( and ) were miss= ing, but from the tests it seems that is not how it should work, in particul= ar if after (or before) we have some macro argument and it is not followed (or preceded) by ##, then it should be macro expanded even when __VA_OP= T__ is after ## or ) is followed by ##. And it seems that not removing any padding tokens isn't possible either, because the expansion of the arguments typically has a padding token at the start and end and those at least according to the testsuite need to go. It is unclear if it would be en= ough to remove just one or if all padding tokens should be removed. Anyway, e.g. the previous removal of all padding tokens at the end of __VA_OPT__ is undesirable, as it e.g. eats also the padding tokens need= ed for the H4 example from the paper. 2021-09-01 Jakub Jelinek PR preprocessor/101488 * macro.c (replace_args): Fix up handling of CPP_PADDING tokens= at the start or end of __VA_OPT__ arguments when preceeded or followed= by ##. * c-c++-common/cpp/va-opt-3.c: Adjust expected output. * c-c++-common/cpp/va-opt-7.c: New test.=