https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101488

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:e928cf47f350e46eacb48ed954112e603ef3800a

commit r12-3298-ge928cf47f350e46eacb48ed954112e603ef3800a
Author: Jakub Jelinek <ja...@redhat.com>
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 clang
    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 missing,
    but from the tests it seems that is not how it should work, in particular
    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_OPT__
    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 enough
    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 needed
    for the H4 example from the paper.

    2021-09-01  Jakub Jelinek  <ja...@redhat.com>

            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.
  • [Bug c++/101488] Implement p104... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to