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

--- Comment #4 from GCC 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:6e77a83ffbe4253c306b5b3750cf4ee38e5ce071

commit r15-9331-g6e77a83ffbe4253c306b5b3750cf4ee38e5ce071
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Apr 9 12:27:38 2025 +0200

    libcpp: Fix error recovery after use of __VA_ARGS__ as macro argument
[PR118674]

    The following testcase ICEs after emitting one pedwarn (about using
    __VA_ARGS__ in a place where it shouldn't be used) and one error.
    The error is emitted by _cpp_save_parameter where it sees the node
    has been used already earlier.  But unlike the other _cpp_save_parameter
    caller which does goto out; if it returns false, this call with explicit
    __VA_ARGS__ doesn't and if it increments number of parameters etc. after
    the error, we then try to unsave it twice.

    The following patch fixes it by doing the goto out in that case too,
    the macro will then not be considered as variable arguments macro,
    but for error recovery I think that is fine.
    The other option would be before the other _cpp_save_parameter caller
    check if the node is pfile->spec_nodes.n__VA_ARGS__ and in that case
    also error and goto out, but that seems more expensive than this for
    the common case that the macro definition is correct.

    2025-04-09  Jakub Jelinek  <ja...@redhat.com>

            PR preprocessor/118674
            * macro.cc (parse_params) <case CPP_ELLIPSIS>: If
_cpp_save_parameter
            failed for __VA_ARGS__, goto out.

            * gcc.dg/cpp/pr118674.c: New test.

Reply via email to