* cp-tree.h (COND_EXPR_IS_VEC_DELETE): New.
* init.c (build_vec_delete_1): Set it.
* constexpr.c (potential_constant_expression_1) [COND_EXPR]: Check it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233987
138bc75d-0d04-0410-961f-
82ee72b054a4
+2016-03-04 Jason Merrill <jason@redhat.com>
+
+ PR c++/69203
+ * cp-tree.h (COND_EXPR_IS_VEC_DELETE): New.
+ * init.c (build_vec_delete_1): Set it.
+ * constexpr.c (potential_constant_expression_1) [COND_EXPR]: Check it.
+
2016-03-04 Jakub Jelinek <jakub@redhat.com>
* decl.c (start_preparsed_function): Don't emit start clobber at the
return false;
return true;
- case IF_STMT:
case COND_EXPR:
+ if (COND_EXPR_IS_VEC_DELETE (t))
+ {
+ if (flags & tf_error)
+ error_at (location_of (t),
+ "%<delete[]%> is not a constant-expression");
+ return false;
+ }
+ /* Fall through. */
+ case IF_STMT:
case VEC_COND_EXPR:
/* If the condition is a known constant, we know which of the legs we
care about; otherwise we only require that the condition and
/* Usage of TREE_LANG_FLAG_?:
0: IDENTIFIER_MARKED (IDENTIFIER_NODEs)
NEW_EXPR_USE_GLOBAL (in NEW_EXPR).
+ COND_EXPR_IS_VEC_DELETE (in COND_EXPR).
DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR).
COMPOUND_EXPR_OVERLOADED (in COMPOUND_EXPR).
CLEANUP_P (in TRY_BLOCK)
#define STMT_EXPR_NO_SCOPE(NODE) \
TREE_LANG_FLAG_0 (STMT_EXPR_CHECK (NODE))
+#define COND_EXPR_IS_VEC_DELETE(NODE) \
+ TREE_LANG_FLAG_0 (COND_EXPR_CHECK (NODE))
+
/* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
sense of `same'. */
#define same_type_p(TYPE1, TYPE2) \
TREE_NO_WARNING (cond) = 1;
body = build3_loc (input_location, COND_EXPR, void_type_node,
cond, body, integer_zero_node);
+ COND_EXPR_IS_VEC_DELETE (body) = true;
body = build1 (NOP_EXPR, void_type_node, body);
if (controller)
--- /dev/null
+// PR c++/69203
+// { dg-do compile { target c++11 } }
+
+struct A { ~A(); };
+constexpr int f(int i) { return i; }
+constexpr int g(A* ap)
+{
+ return f((delete[] ap, 42)); // { dg-message "" }
+}
+
+A a;
+constexpr int i = g(&a); // { dg-error "" }