re PR c++/24780 (ICE set_mem_attributes_minus_bitpos)
authorJakub Jelinek <jakub@redhat.com>
Sat, 12 Nov 2005 20:44:55 +0000 (21:44 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 12 Nov 2005 20:44:55 +0000 (21:44 +0100)
PR c++/24780
* typeck.c (complete_type): Set TYPE_NEEDS_CONSTRUCTING
and TYPE_HAS_NONTRIVIAL_DESTRUCTOR flags for all variants
of array type.

* g++.dg/opt/pr24780.C: New test.

From-SVN: r106833

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr24780.C [new file with mode: 0644]

index 5736a0d2445468a963242ad38ef864859769ecfe..6edab04fe2bb488927df1ea676f0a05f737aeb14 100644 (file)
@@ -1,5 +1,10 @@
 2005-11-12  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/24780
+       * typeck.c (complete_type): Set TYPE_NEEDS_CONSTRUCTING
+       and TYPE_HAS_NONTRIVIAL_DESTRUCTOR flags for all variants
+       of array type.
+
        PR c++/24761
        * pt.c (tsubst_copy_asm_operands): New function.
        (tsubst_expr) <case ASM_EXPR>: Use it.
index b9be6fd694ff6601eb26340f2de58f6961d27f7b..31e2d6f58fc76c87b8023a0e6df7d8c17261df71 100644 (file)
@@ -107,12 +107,18 @@ complete_type (tree type)
   else if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type))
     {
       tree t = complete_type (TREE_TYPE (type));
+      unsigned int needs_constructing, has_nontrivial_dtor;
       if (COMPLETE_TYPE_P (t) && !dependent_type_p (type))
        layout_type (type);
-      TYPE_NEEDS_CONSTRUCTING (type)
+      needs_constructing
        = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (t));
-      TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
+      has_nontrivial_dtor
        = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (t));
+      for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
+       {
+         TYPE_NEEDS_CONSTRUCTING (t) = needs_constructing;
+         TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = has_nontrivial_dtor;
+       }
     }
   else if (CLASS_TYPE_P (type) && CLASSTYPE_TEMPLATE_INSTANTIATION (type))
     instantiate_class_template (TYPE_MAIN_VARIANT (type));
index 5500af19e5f19bb53a0c47d102b072d5b24afdf4..e9cc432b966bef021ae5e3f9bcc82ecddfc44b4e 100644 (file)
@@ -1,5 +1,8 @@
 2005-11-12  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/24780
+       * g++.dg/opt/pr24780.C: New test.
+
        PR c++/24761
        * g++.dg/template/asm1.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/opt/pr24780.C b/gcc/testsuite/g++.dg/opt/pr24780.C
new file mode 100644 (file)
index 0000000..7baad38
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/24780
+// { dg-do compile }
+
+template<typename S=int>
+struct Move {
+  Move();
+  static Move<S> const MOVES[2][2];
+};
+template<typename S>
+  Move<S> const Move<S>::MOVES[2][2]={};
+typedef Move<int> const MoveClass;
+void moves(int x, int y) {
+  &MoveClass::MOVES[x][y];
+}