diff options
author | Jason Merrill <jason@redhat.com> | 2011-06-26 21:07:34 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-06-26 21:07:34 -0400 |
commit | 8c2f5419ea3a4c07d9c2cf2dfbc9bf52702e5bea (patch) | |
tree | b3c6dfa58187de1d37cb50849814e31316a35059 | |
parent | 149c083d32ca58a9a53d7e02f81f26886be7c00b (diff) | |
download | gcc-8c2f5419ea3a4c07d9c2cf2dfbc9bf52702e5bea.zip gcc-8c2f5419ea3a4c07d9c2cf2dfbc9bf52702e5bea.tar.gz gcc-8c2f5419ea3a4c07d9c2cf2dfbc9bf52702e5bea.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C | 2 |
4 files changed, 12 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 117c13e..6629549 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,11 @@ 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. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5404c9f..d1af0c6 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 01b111c..1b29f6e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 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. diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C index b3fb9a8..de17f3d 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" } |