On 8/20/26 11:59 AM, Jakub Jelinek wrote:
Hi!

The following patch implements the C++29
P3822R2 - Conditional noexcept specifiers in compound requirements
paper.  For mangling I've used what the clang++ fork mentioned in the
paper uses, so no N for no noexcept (as before) or noexcept (false),
N for noexcept (as before) or noexcept (true) and
C <expression> for noexcept (<expression>).  I've also checked all these
new testcases against that clang++ fork on godbolt (again, link in the
paper), everything is accepted or rejected the same in both compilers,
just there is apparently a difference in the mangling but preexisting and
unrelated to this exact patch (the no N vs. N vs. C <expression> is actually
the same).

So far lightly tested, ok for trunk if it passes full bootstrap/regtest?

2026-08-20  Jakub Jelinek  <[email protected]>

        PR c++/125822
gcc/c-family/
        * c-cppbuiltin.cc (c_cpp_builtins): Define __cpp_concepts to 202606L
        rather than 202002L for C++29.
gcc/cp/
        * cp-tree.def: Implement C++29 P3822R2 - Conditional noexcept
        specifiers in compound requirements.
        (COMPOUND_REQ): Use 3 operands rather than 2, adjust comment.
        * cp-tree.h (COMPOUND_REQ_NOEXCEPT_P): Remove.
        (finish_compound_requirement): Change last argument from bool to
        tree.
        * parser.cc (cp_parser_compound_requirement): Parse C++29 conditional

FWIW this line...

        noexcept in compound requirement.  Pass a tree to
        finish_compound_requirement rather than bool.
        * constraint.cc (tsubst_compound_requirement): Read noexcept from
        TREE_OPERAND (req, 2) rather than COMPOUND_REQ_NOEXCEPT_P (req),
        instantiate, convert, evaluate and pass to finish_compound_requirement.

...and this one exceed 80 columns in 'git log' due to git adding padding on the left; I like to wrap at 76 columns as a result.

        (finish_compound_requirement): Change last argument from bool to
        tree, store it as third operand of COMPOUND_REQ rather than in
        COMPOUND_REQ_NOEXCEPT_P flag and call check_for_bare_parameter_packs
        on it.
        * cxx-pretty-print.cc (pp_cxx_compound_requirement): Print noexcept
        with argument if TREE_OPERAND (t, 2) is neither true nor false
        constant and check it for printing "noexcept" instead oof
        COMPOUND_REQ_NOEXCEPT_P flag.
        * mangle.cc (write_requirement): Don't use COMPOUND_REQ_NOEXCEPT_P
        flag, instead mangle without N or with N if third operand is false
        or true constant and as C <expression> otherwise.
gcc/testsuite/
        * g++.dg/cpp29/complex-req-noexcept1.C: New test.
        * g++.dg/cpp29/complex-req-noexcept2.C: New test.
        * g++.dg/cpp29/complex-req-noexcept3.C: New test.
        * g++.dg/cpp29/complex-req-noexcept4.C: New test.
        * g++.dg/cpp29/complex-req-noexcept5.C: New test.
        * g++.dg/cpp29/feat-cxx29.C: Expect __cpp_concepts 202606L rather
        than 202002L for C++29.

--- gcc/c-family/c-cppbuiltin.cc.jj     2026-08-06 11:48:09.026003282 +0200
+++ gcc/c-family/c-cppbuiltin.cc        2026-08-20 17:03:31.614072266 +0200

Note that this is still different from typical git output (with a/ and b/), so git am (and git pw patch apply, b4 shazam, etc) fail with errors like

Patch failed at 0001 c++: Implement C++29 P3822R2 - Conditional noexcept specifiers in compound requirements [PR125822]
 error: cp/cp-tree.def: does not exist in index

But the patch is OK.

Jason

Reply via email to