Commit 8c2f5419 by Jason Merrill Committed by Jason Merrill

re PR c++/49528 (g++ fails to destroy temporary object when subobject is used to…

re PR c++/49528 (g++ fails to destroy temporary object when subobject is used to initialize a reference)

	PR c++/49528
	* semantics.c (potential_constant_expression_1): Check
	for non-literality rather than cleanup.
	(cxx_eval_constant_expression): Likewise.

From-SVN: r175417
parent 149c083d
2011-06-26 Jason Merrill <jason@redhat.com>
PR c++/49528
* semantics.c (potential_constant_expression_1): Check
for non-literality rather than cleanup.
(cxx_eval_constant_expression): Likewise.
PR c++/49528
* semantics.c (potential_constant_expression_1): A TARGET_EXPR
with a cleanup isn't constant.
(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;
}
......
2011-06-26 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/constexpr-cleanup.C: Tweak error message.
PR c++/49528
* g++.dg/init/ref19.C: New.
* g++.dg/cpp0x/constexpr-cleanup.C: New.
......
......@@ -6,4 +6,4 @@ struct A
~A();
};
constexpr int i = A().i; // { dg-error "destruction" }
constexpr int i = A().i; // { dg-error "non-literal" }
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