aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r--gcc/cp/constexpr.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index fc4a3f7..218faec 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -3525,6 +3525,25 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
non_constant_p, overflow_p, jump_target);
break;
+ case REQUIRES_EXPR:
+ /* It's possible to get a requires-expression in a constant
+ expression. For example:
+
+ template<typename T> concept bool C() {
+ return requires (T t) { t; };
+ }
+
+ template<typename T> requires !C<T>() void f(T);
+
+ Normalization leaves f with the associated constraint
+ '!requires (T t) { ... }' which is not transformed into
+ a constraint. */
+ if (!processing_template_decl)
+ return evaluate_constraint_expression (t, NULL_TREE);
+ else
+ *non_constant_p = true;
+ return t;
+
default:
if (STATEMENT_CODE_P (TREE_CODE (t)))
{
@@ -3897,6 +3916,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
case PLACEHOLDER_EXPR:
case BREAK_STMT:
case CONTINUE_STMT:
+ case REQUIRES_EXPR:
return true;
case AGGR_INIT_EXPR: