return false;
if (t == NULL_TREE)
return true;
+ location_t loc = EXPR_LOC_OR_LOC (t, input_location);
if (TREE_THIS_VOLATILE (t) && !DECL_P (t))
{
if (flags & tf_error)
- error ("expression %qE has side-effects", t);
+ error_at (loc, "expression %qE has side-effects", t);
return false;
}
if (CONSTANT_CLASS_P (t))
{
/* fold_call_expr can't do anything with IFN calls. */
if (flags & tf_error)
- error_at (EXPR_LOC_OR_LOC (t, input_location),
- "call to internal function %qE", t);
+ error_at (loc, "call to internal function %qE", t);
return false;
}
}
{
if (flags & tf_error)
{
- error_at (EXPR_LOC_OR_LOC (t, input_location),
- "call to non-constexpr function %qD", fun);
+ error_at (loc, "call to non-constexpr function %qD",
+ fun);
explain_invalid_constexpr_fn (fun);
}
return false;
&& !integer_zerop (from))
{
if (flags & tf_error)
- error_at (EXPR_LOC_OR_LOC (t, input_location),
- "reinterpret_cast from integer to pointer");
+ error_at (loc, "reinterpret_cast from integer to pointer");
return false;
}
return (RECUR (from, TREE_CODE (t) != VIEW_CONVERT_EXPR));
&& !DECL_DECLARED_CONSTEXPR_P (DECL_CONTEXT (x)))
{
if (flags & tf_error)
- error ("use of %<this%> in a constant expression");
+ error_at (loc, "use of %<this%> in a constant expression");
return false;
}
return true;
case DELETE_EXPR:
case VEC_DELETE_EXPR:
case THROW_EXPR:
+ case OMP_PARALLEL:
+ case OMP_TASK:
+ case OMP_FOR:
+ case OMP_DISTRIBUTE:
+ case OMP_TASKLOOP:
+ case OMP_TEAMS:
+ case OMP_TARGET_DATA:
+ case OMP_TARGET:
+ case OMP_SECTIONS:
+ case OMP_ORDERED:
+ case OMP_CRITICAL:
+ case OMP_SINGLE:
+ case OMP_SECTION:
+ case OMP_MASTER:
+ case OMP_TASKGROUP:
+ case OMP_TARGET_UPDATE:
+ case OMP_TARGET_ENTER_DATA:
+ case OMP_TARGET_EXIT_DATA:
case OMP_ATOMIC:
case OMP_ATOMIC_READ:
case OMP_ATOMIC_CAPTURE_OLD:
case OMP_ATOMIC_CAPTURE_NEW:
+ case OACC_PARALLEL:
+ case OACC_KERNELS:
+ case OACC_DATA:
+ case OACC_HOST_DATA:
+ case OACC_LOOP:
+ case OACC_CACHE:
+ case OACC_DECLARE:
+ case OACC_ENTER_DATA:
+ case OACC_EXIT_DATA:
+ case OACC_UPDATE:
+ case CILK_SIMD:
+ case CILK_FOR:
/* GCC internal stuff. */
case VA_ARG_EXPR:
case OBJ_TYPE_REF:
case AT_ENCODE_EXPR:
fail:
if (flags & tf_error)
- error ("expression %qE is not a constant expression", t);
+ error_at (loc, "expression %qE is not a constant expression", t);
return false;
case TYPEID_EXPR:
&& TYPE_POLYMORPHIC_P (TREE_TYPE (e)))
{
if (flags & tf_error)
- error ("typeid-expression is not a constant expression "
- "because %qE is of polymorphic type", e);
+ error_at (loc, "typeid-expression is not a constant expression "
+ "because %qE is of polymorphic type", e);
return false;
}
return true;
constant expression. */
{
if (flags & tf_error)
- error ("cast to non-integral type %qT in a constant expression",
- TREE_TYPE (t));
+ error_at (loc,
+ "cast to non-integral type %qT in a constant expression",
+ TREE_TYPE (t));
return false;
}
{
if (flags & tf_error)
{
- error ("temporary of non-literal type %qT in a "
- "constant expression", TREE_TYPE (t));
+ error_at (loc, "temporary of non-literal type %qT in a "
+ "constant expression", TREE_TYPE (t));
explain_non_literal_class (TREE_TYPE (t));
}
return false;
if (COND_EXPR_IS_VEC_DELETE (t))
{
if (flags & tf_error)
- error_at (location_of (t),
- "%<delete[]%> is not a constant expression");
+ error_at (loc, "%<delete[]%> is not a constant expression");
return false;
}
/* Fall through. */
want_rval, strict, tf_none))
return true;
if (flags & tf_error)
- error ("expression %qE is not a constant expression", t);
+ error_at (loc, "expression %qE is not a constant expression", t);
return false;
case VEC_INIT_EXPR:
return true;
if (flags & tf_error)
{
- error ("non-constant array initialization");
+ error_at (loc, "non-constant array initialization");
diagnose_non_constexpr_vec_init (t);
}
return false;
if (breaks (target) || continues (target))
return true;
if (flags & tf_error)
- error ("%<goto%> is not a constant expression");
+ error_at (loc, "%<goto%> is not a constant expression");
return false;
}
OMP_TEAMS_CLAUSES (ret) = clauses;
OMP_TEAMS_BODY (ret) = body;
OMP_TEAMS_COMBINED (ret) = 1;
+ SET_EXPR_LOCATION (ret, loc);
return add_stmt (ret);
}
}
TREE_TYPE (stmt) = void_type_node;
OMP_TEAMS_CLAUSES (stmt) = clauses;
OMP_TEAMS_BODY (stmt) = cp_parser_omp_structured_block (parser, if_p);
+ SET_EXPR_LOCATION (stmt, loc);
return add_stmt (stmt);
}
OMP_TARGET_CLAUSES (stmt) = cclauses[C_OMP_CLAUSE_SPLIT_TARGET];
OMP_TARGET_BODY (stmt) = body;
OMP_TARGET_COMBINED (stmt) = 1;
+ SET_EXPR_LOCATION (stmt, pragma_tok->location);
add_stmt (stmt);
pc = &OMP_TARGET_CLAUSES (stmt);
goto check_clauses;
--- /dev/null
+// PR c++/79664
+// { dg-do compile }
+// { dg-options "-std=c++14 -fopenmp" }
+
+constexpr int
+f1 ()
+{
+ int i = 0;
+#pragma omp parallel for // { dg-error "is not a constant expression" }
+ for (i = 0; i < 10; ++i)
+ ;
+ return 0;
+}
+
+constexpr int
+f2 ()
+{
+ int i = 0;
+#pragma omp parallel // { dg-error "is not a constant expression" }
+ i = 5;
+ return 0;
+}
+
+constexpr int
+f3 ()
+{
+ int i = 0;
+#pragma omp task // { dg-error "is not a constant expression" }
+ i = 5;
+ return 0;
+}
+
+constexpr int
+f4 ()
+{
+ int i = 0;
+#pragma omp for // { dg-error "is not a constant expression" }
+ for (i = 0; i < 10; ++i)
+ ;
+ return 0;
+}
+
+constexpr int
+f5 ()
+{
+ int i = 0;
+#pragma omp taskloop // { dg-error "is not a constant expression" }
+ for (i = 0; i < 10; ++i)
+ ;
+ return 0;
+}
+
+constexpr int
+f6 ()
+{
+ int i = 0;
+#pragma omp target teams // { dg-error "is not a constant expression" }
+ i = 5;
+ return 0;
+}
+
+constexpr int
+f7 ()
+{
+ int i = 0;
+#pragma omp target data map(tofrom:i) // { dg-error "is not a constant expression" }
+ i = 5;
+ return 0;
+}
+
+constexpr int
+f8 ()
+{
+ int i = 0;
+#pragma omp target // { dg-error "is not a constant expression" }
+ i = 5;
+ return 0;
+}
+
+constexpr int
+f9 ()
+{
+ int i = 0;
+#pragma omp sections // { dg-error "is not a constant expression" }
+ {
+#pragma omp section
+ i = 5;
+ }
+ return 0;
+}
+
+constexpr int
+f10 ()
+{
+ int i = 0;
+#pragma omp ordered // { dg-error "is not a constant expression" }
+ i = 1;
+ return 0;
+}
+
+constexpr int
+f11 ()
+{
+ int i = 0;
+#pragma omp critical // { dg-error "is not a constant expression" }
+ i = 1;
+ return 0;
+}
+
+constexpr int
+f12 ()
+{
+ int i = 0;
+#pragma omp single // { dg-error "is not a constant expression" }
+ i = 1;
+ return 0;
+}
+
+constexpr int
+f13 ()
+{
+ int i = 0;
+#pragma omp master // { dg-error "is not a constant expression" }
+ i = 1;
+ return 0;
+}
+
+constexpr int
+f14 ()
+{
+ int i = 0;
+#pragma omp taskgroup // { dg-error "is not a constant expression" }
+ i = 1;
+ return 0;
+}
+
+constexpr int
+f15 ()
+{
+ int i = 0;
+#pragma omp target update to(i) // { dg-error "is not a constant expression" }
+ i = 1;
+ return 0;
+}
+
+constexpr int
+f16 ()
+{
+ int i = 0;
+#pragma omp target update to(i) // { dg-error "is not a constant expression" }
+ return 0;
+}
+
+constexpr int
+f17 ()
+{
+ int i = 0;
+#pragma omp target enter data map(to:i) // { dg-error "is not a constant expression" }
+ return 0;
+}
+
+constexpr int
+f18 ()
+{
+ int i = 0;
+#pragma omp target exit data map(from:i) // { dg-error "is not a constant expression" }
+ return 0;
+}