* cvt.c (convert_to_void): Handle null op1.

From-SVN: r170007
This commit is contained in:
Jason Merrill 2011-02-10 11:29:58 -05:00 committed by Jason Merrill
parent 69f36ba6bd
commit cb8384a3f5
4 changed files with 16 additions and 4 deletions

View File

@ -1,5 +1,7 @@
2011-02-09 Jason Merrill <jason@redhat.com>
* cvt.c (convert_to_void): Handle null op1.
* class.c (type_has_constexpr_default_constructor): Make sure the
caller stripped an enclosing array.
* init.c (perform_member_init): Strip arrays before calling it.

View File

@ -892,20 +892,24 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain)
/* The two parts of a cond expr might be separate lvalues. */
tree op1 = TREE_OPERAND (expr,1);
tree op2 = TREE_OPERAND (expr,2);
bool side_effects = TREE_SIDE_EFFECTS (op1) || TREE_SIDE_EFFECTS (op2);
bool side_effects = ((op1 && TREE_SIDE_EFFECTS (op1))
|| TREE_SIDE_EFFECTS (op2));
tree new_op1, new_op2;
new_op1 = NULL_TREE;
if (implicit != ICV_CAST && !side_effects)
{
new_op1 = convert_to_void (op1, ICV_SECOND_OF_COND, complain);
if (op1)
new_op1 = convert_to_void (op1, ICV_SECOND_OF_COND, complain);
new_op2 = convert_to_void (op2, ICV_THIRD_OF_COND, complain);
}
else
{
new_op1 = convert_to_void (op1, ICV_CAST, complain);
if (op1)
new_op1 = convert_to_void (op1, ICV_CAST, complain);
new_op2 = convert_to_void (op2, ICV_CAST, complain);
}
expr = build3 (COND_EXPR, TREE_TYPE (new_op1),
expr = build3 (COND_EXPR, TREE_TYPE (new_op2),
TREE_OPERAND (expr, 0), new_op1, new_op2);
break;
}

View File

@ -1,5 +1,7 @@
2011-02-09 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/regress/ext-cond1.C: Copy from ext/cond1.C.
* g++.dg/cpp0x/regress/abi-empty7.C: New.
* g++.dg/cpp0x/regress: New directory.

View File

@ -0,0 +1,4 @@
// PR c++/12515
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
template<int> void foo() { 0 ?: 0; }