re PR c++/49528 (g++ fails to destroy temporary object when subobject is used to...
authorJason Merrill <jason@redhat.com>
Mon, 27 Jun 2011 01:07:34 +0000 (21:07 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 27 Jun 2011 01:07:34 +0000 (21:07 -0400)
PR c++/49528
* semantics.c (potential_constant_expression_1): Check
for non-literality rather than cleanup.
(cxx_eval_constant_expression): Likewise.

From-SVN: r175417

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C

index 117c13e98673f2a789ddb3d55add5a2ff5a67cae..6629549276010a268d524bea72fb73267ab00a8f 100644 (file)
@@ -1,5 +1,10 @@
 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.
index 5404c9f2a56995210e1c4b9544b48493bff5c6c4..d1af0c6bc2db6bdb98b8f6c98fdad406fa554ec8 100644 (file)
@@ -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;
        }
index 01b111cef6b2a7340509b0c0c4902dadf75bfd5c..1b29f6e6f09cd5e73a6e553a13c79444c654209a 100644 (file)
@@ -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.
index b3fb9a8deca9d763cb2603def09944c19815a2fc..de17f3ddb2560afb46820086d4c1fff95444b693 100644 (file)
@@ -6,4 +6,4 @@ struct A
   ~A();
 };
 
-constexpr int i = A().i;       // { dg-error "destruction" }
+constexpr int i = A().i;       // { dg-error "non-literal" }