]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: requires-expression folding [PR101182]
authorPatrick Palka <ppalka@redhat.com>
Thu, 24 Jun 2021 15:29:02 +0000 (11:29 -0400)
committerPatrick Palka <ppalka@redhat.com>
Tue, 13 Jul 2021 13:53:27 +0000 (09:53 -0400)
commit0f00006c007f3f7e9b6fdd9906ed1e4c791f6b15
treefc4505032501c24d239840195560c234279e398f
parent927548b42c4850094eb41c7ae882cbe219b24231
c++: requires-expression folding [PR101182]

Here we're crashing because cp_fold_function walks into the (templated)
requirements of a requires-expression outside a template, but the
folding routines aren't prepared to handle templated trees.  This patch
fixes this by making cp_fold use evaluate_requires_expr to fold a
requires-expression as a whole, which also means we no longer need to
explicitly do so during gimplification.  (Note that we delay folding
of such requires-expressions for sake of better diagnostics when one is
used as the condition of a failed static_assert.)

PR c++/101182

gcc/cp/ChangeLog:

* constraint.cc (evaluate_requires_expr): Adjust function comment.
* cp-gimplify.c (cp_genericize_r) <case REQUIRES_EXPR>: Move to ...
(cp_fold) <case REQUIRES_EXPR>: ... here.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-requires25.C: New test.

(cherry picked from commit c06493dc30afbf65b14d783c7cd53f20877ef577)
gcc/cp/constraint.cc
gcc/cp/cp-gimplify.c
gcc/testsuite/g++.dg/cpp2a/concepts-requires25.C [new file with mode: 0644]