aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/constexpr.cc')
-rw-r--r--gcc/cp/constexpr.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index d647a09..48327fb 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -3540,6 +3540,9 @@ reduced_constant_expression_p (tree t)
/* Even if we can't lower this yet, it's constant. */
return true;
+ case OMP_DECLARE_MAPPER:
+ return true;
+
case CONSTRUCTOR:
/* And we need to handle PTRMEM_CST wrapped in a CONSTRUCTOR. */
tree field;
@@ -7849,6 +7852,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case LABEL_EXPR:
case CASE_LABEL_EXPR:
case PREDICT_EXPR:
+ case OMP_DECLARE_MAPPER:
return t;
case PARM_DECL:
@@ -10536,6 +10540,11 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
"expression", t);
return false;
+ case OMP_DECLARE_MAPPER:
+ /* This can be used to initialize VAR_DECLs: it's treated as a magic
+ constant. */
+ return true;
+
case ASM_EXPR:
if (flags & tf_error)
inline_asm_in_constexpr_error (loc, fundef_p);
@@ -11033,6 +11042,22 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
return true;
}
+ /* We technically should never encounter this, but handling a generic
+ lambda checks the function body before instantiation to see if it can be
+ declared constexpr. This is currently fairly buggy and not respected
+ by other parts of the code though. */
+ case OMP_ALLOCATE:
+ /* This is the only case I observed this, we want to know if other cases
+ suddenly manifest. */
+ gcc_assert (cxx_dialect >= cxx17
+ && processing_template_decl
+ && LAMBDA_FUNCTION_P (current_function_decl));
+ /* OpenMP does not currently allow directives in constexpr functions.
+ However as hinted at above, returning false here doesn't actually stop
+ lambdas from being called in constant expressions.
+ We still return false in case that changes in the future. */
+ return false;
+
default:
if (objc_non_constant_expr_p (t))
return false;