From: Jason Merrill Date: Mon, 27 Jun 2011 01:07:34 +0000 (-0400) Subject: re PR c++/49528 (g++ fails to destroy temporary object when subobject is used to... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8c2f5419ea3a4c07d9c2cf2dfbc9bf52702e5bea;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 117c13e9867..66295492760 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2011-06-26 Jason Merrill + 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. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5404c9f2a56..d1af0c6bc2d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 01b111cef6b..1b29f6e6f09 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-06-26 Jason Merrill + * 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. diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C index b3fb9a8deca..de17f3ddb25 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C @@ -6,4 +6,4 @@ struct A ~A(); }; -constexpr int i = A().i; // { dg-error "destruction" } +constexpr int i = A().i; // { dg-error "non-literal" }