Commit d5bcd6d4 by Jason Merrill Committed by Jason Merrill

re PR c++/69203 (ICE in potential_constant_expression_1, at cp/constexpr.c:4754)

	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.

From-SVN: r233987
parent e94da7c6
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> 2016-03-04 Jakub Jelinek <jakub@redhat.com>
* decl.c (start_preparsed_function): Don't emit start clobber at the * decl.c (start_preparsed_function): Don't emit start clobber at the
......
...@@ -4885,8 +4885,16 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, ...@@ -4885,8 +4885,16 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
return false; return false;
return true; return true;
case IF_STMT:
case COND_EXPR: 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: case VEC_COND_EXPR:
/* If the condition is a known constant, we know which of the legs we /* If the condition is a known constant, we know which of the legs we
care about; otherwise we only require that the condition and care about; otherwise we only require that the condition and
......
...@@ -107,6 +107,7 @@ operator == (const cp_expr &lhs, tree rhs) ...@@ -107,6 +107,7 @@ operator == (const cp_expr &lhs, tree rhs)
/* Usage of TREE_LANG_FLAG_?: /* Usage of TREE_LANG_FLAG_?:
0: IDENTIFIER_MARKED (IDENTIFIER_NODEs) 0: IDENTIFIER_MARKED (IDENTIFIER_NODEs)
NEW_EXPR_USE_GLOBAL (in NEW_EXPR). NEW_EXPR_USE_GLOBAL (in NEW_EXPR).
COND_EXPR_IS_VEC_DELETE (in COND_EXPR).
DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR). DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR).
COMPOUND_EXPR_OVERLOADED (in COMPOUND_EXPR). COMPOUND_EXPR_OVERLOADED (in COMPOUND_EXPR).
CLEANUP_P (in TRY_BLOCK) CLEANUP_P (in TRY_BLOCK)
...@@ -404,6 +405,9 @@ typedef struct ptrmem_cst * ptrmem_cst_t; ...@@ -404,6 +405,9 @@ typedef struct ptrmem_cst * ptrmem_cst_t;
#define STMT_EXPR_NO_SCOPE(NODE) \ #define STMT_EXPR_NO_SCOPE(NODE) \
TREE_LANG_FLAG_0 (STMT_EXPR_CHECK (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 /* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
sense of `same'. */ sense of `same'. */
#define same_type_p(TYPE1, TYPE2) \ #define same_type_p(TYPE1, TYPE2) \
......
...@@ -3685,6 +3685,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, ...@@ -3685,6 +3685,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
TREE_NO_WARNING (cond) = 1; TREE_NO_WARNING (cond) = 1;
body = build3_loc (input_location, COND_EXPR, void_type_node, body = build3_loc (input_location, COND_EXPR, void_type_node,
cond, body, integer_zero_node); cond, body, integer_zero_node);
COND_EXPR_IS_VEC_DELETE (body) = true;
body = build1 (NOP_EXPR, void_type_node, body); body = build1 (NOP_EXPR, void_type_node, body);
if (controller) if (controller)
......
// 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 "" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment