+2011-06-26 Jason Merrill <jason@redhat.com>
+
+ PR c++/49528
+ * semantics.c (potential_constant_expression_1): A TARGET_EXPR
+ with a cleanup isn't constant.
+ (cxx_eval_constant_expression): Likewise.
+ * init.c (expand_default_init): Use maybe_constant_init.
+
2011-06-24 Jakub Jelinek <jakub@redhat.com>
PR c++/46400
tree fn = get_callee_fndecl (rval);
if (fn && DECL_DECLARED_CONSTEXPR_P (fn))
{
- tree e = maybe_constant_value (rval);
+ tree e = maybe_constant_init (rval);
if (TREE_CONSTANT (e))
rval = build2 (INIT_EXPR, type, exp, e);
}
break;
case TARGET_EXPR:
+ /* A cleanup isn't constant. */
+ if (TARGET_EXPR_CLEANUP (t))
+ {
+ if (!allow_non_constant)
+ error ("temporary of type %qT needing destruction in a "
+ "constant expression", TREE_TYPE (t));
+ *non_constant_p = true;
+ break;
+ }
+ /* else fall through. */
case INIT_EXPR:
/* Pass false for 'addr' because these codes indicate
initialization of a temporary. */
return potential_constant_expression_1 (TREE_OPERAND (t, 1),
want_rval, flags);
- case INIT_EXPR:
case TARGET_EXPR:
+ /* A cleanup isn't constant. */
+ if (TARGET_EXPR_CLEANUP (t))
+ {
+ if (flags & tf_error)
+ error ("temporary of type %qT needing destruction in a "
+ "constant expression", TREE_TYPE (t));
+ return false;
+ }
+ case INIT_EXPR:
return potential_constant_expression_1 (TREE_OPERAND (t, 1),
rval, flags);
+2011-06-26 Jason Merrill <jason@redhat.com>
+
+ PR c++/49528
+ * g++.dg/init/ref19.C: New.
+ * g++.dg/cpp0x/constexpr-cleanup.C: New.
+
2011-06-26 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/48377