commit 81e093c1d6f2657c8c3c2abc2af559111ca82da4
Author: Jason Merrill <jason@redhat.com>
Date: Sun Jun 26 15:23:00 2011 -0400
PR c++/49528
* semantics.c (potential_constant_expression_1): Check
for non-literality rather than cleanup.
(cxx_eval_constant_expression): Likewise.
@@ -7020,11 +7020,10 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
break;
case TARGET_EXPR:
- /* A cleanup isn't constant. */
- if (TARGET_EXPR_CLEANUP (t))
+ if (!literal_type_p (TREE_TYPE (t)))
{
if (!allow_non_constant)
- error ("temporary of type %qT needing destruction in a "
+ error ("temporary of non-literal type %qT in a "
"constant expression", TREE_TYPE (t));
*non_constant_p = true;
break;
@@ -7851,11 +7850,10 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
want_rval, flags);
case TARGET_EXPR:
- /* A cleanup isn't constant. */
- if (TARGET_EXPR_CLEANUP (t))
+ if (!literal_type_p (TREE_TYPE (t)))
{
if (flags & tf_error)
- error ("temporary of type %qT needing destruction in a "
+ error ("temporary of non-literal type %qT in a "
"constant expression", TREE_TYPE (t));
return false;
}
@@ -6,4 +6,4 @@ struct A
~A();
};
-constexpr int i = A().i; // { dg-error "destruction" }
+constexpr int i = A().i; // { dg-error "non-literal" }