OSDN Git Service

* semantics.c (finish_compound_literal): Don't put an array
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Apr 2011 04:27:30 +0000 (04:27 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Apr 2011 04:27:30 +0000 (04:27 +0000)
with a dtor in a static variable.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172806 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist47.C [new file with mode: 0644]

index 7c33ce2..5618a3b 100644 (file)
@@ -1,5 +1,10 @@
 2011-04-20  Jason Merrill  <jason@redhat.com>
 
+       * semantics.c (finish_compound_literal): Don't put an array
+       with a dtor in a static variable.
+
+2011-04-20  Jason Merrill  <jason@redhat.com>
+
        PR c++/48594
        * decl2.c (build_offset_ref_call_from_tree): Move
        non-dependency of object outside condition.
index cf8d329..0d80771 100644 (file)
@@ -2333,6 +2333,7 @@ finish_compound_literal (tree type, tree compound_literal)
      represent class temporaries with TARGET_EXPR so we elide copies.  */
   if ((!at_function_scope_p () || CP_TYPE_CONST_P (type))
       && TREE_CODE (type) == ARRAY_TYPE
+      && !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
       && initializer_constant_valid_p (compound_literal, type))
     {
       tree decl = create_temporary_var (type);
index a956416..48ec6f5 100644 (file)
@@ -1,5 +1,9 @@
 2011-04-20  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/initlist47.C: New.
+
+2011-04-20  Jason Merrill  <jason@redhat.com>
+
        * g++.dg/template/const4.C: New.
 
 2011-04-19  Jason Merrill  <jason@redhat.com>
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist47.C b/gcc/testsuite/g++.dg/cpp0x/initlist47.C
new file mode 100644 (file)
index 0000000..b76fb58
--- /dev/null
@@ -0,0 +1,9 @@
+// { dg-options -std=c++0x }
+
+struct A { ~A() = delete; };   // { dg-error "declared" }
+
+int main()
+{
+  typedef const A cA[2];
+  cA{};                                // { dg-error "deleted" }
+}