re PR c++/48029 (ICE in finish_member_declaration() with --param ggc-min-expand=0...
authorJason Merrill <jason@gcc.gnu.org>
Thu, 10 Mar 2011 22:37:22 +0000 (17:37 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 10 Mar 2011 22:37:22 +0000 (17:37 -0500)
PR c++/48029
* stor-layout.c (layout_type): Don't set structural equality
on arrays of incomplete type.
* tree.c (type_hash_eq): Handle comparing them properly.
* cp/pt.c (iterative_hash_template_arg): Remove special case for
ARRAY_TYPE.

From-SVN: r170853

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/stor-layout.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/array22.C [new file with mode: 0644]
gcc/tree.c

index ca2a952d616f70b0dbe530200e029728103e628a..45b83c8994b8873d08cdd0420c342465b8946f3b 100644 (file)
@@ -1,7 +1,14 @@
+2011-03-10  Jason Merrill  <jason@redhat.com>
+
+       PR c++/48029
+       * stor-layout.c (layout_type): Don't set structural equality
+       on arrays of incomplete type.
+       * tree.c (type_hash_eq): Handle comparing them properly.
+
 2011-03-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/48043
-       * config/s390/s390.c (s390_delegitimize_address): Make sure the                                                                            
+       * config/s390/s390.c (s390_delegitimize_address): Make sure the
        result mode matches original rtl mode.
 
 2011-03-10  Nick Clifton  <nickc@redhat.com>
index a3a5bf7c66d5e2d0cbd7e0845eb23f0baa54e98b..a4c394cbf35e556a97192455a6a146d3bda99bfe 100644 (file)
@@ -1,5 +1,9 @@
 2011-03-10  Jason Merrill  <jason@redhat.com>
 
+       PR c++/48029
+       * pt.c (iterative_hash_template_arg): Remove special case for
+       ARRAY_TYPE.
+
        PR c++/47198
        * parser.c (cp_parser_single_declaration): Just return if
        cp_parser_parse_and_diagnose_invalid_type_name complained.
index ac91698ad72c4d300f6275e94cc9ed6ce3d534db..ab2aea3b53679ccf89398f8492da8c6cd27a63d6 100644 (file)
@@ -1569,13 +1569,6 @@ iterative_hash_template_arg (tree arg, hashval_t val)
       val = iterative_hash_object (code, val);
       return iterative_hash_template_arg (TREE_OPERAND (arg, 2), val);
 
-    case ARRAY_TYPE:
-      /* layout_type sets structural equality for arrays of
-        incomplete type, so we can't rely on the canonical type
-        for hashing.  */
-      val = iterative_hash_template_arg (TREE_TYPE (arg), val);
-      return iterative_hash_template_arg (TYPE_DOMAIN (arg), val);
-
     case LAMBDA_EXPR:
       /* A lambda can't appear in a template arg, but don't crash on
         erroneous input.  */
index 9056d7e27c9546d0cdf24d8d79e1e89893538c39..ed36c5b3a5a4cdca479d494ec2530f59a3ed3bea 100644 (file)
@@ -2028,11 +2028,6 @@ layout_type (tree type)
 #else
        TYPE_ALIGN (type) = MAX (TYPE_ALIGN (element), BITS_PER_UNIT);
 #endif
-       if (!TYPE_SIZE (element))
-         /* We don't know the size of the underlying element type, so
-            our alignment calculations will be wrong, forcing us to
-            fall back on structural equality. */
-         SET_TYPE_STRUCTURAL_EQUALITY (type);
        TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (element);
        SET_TYPE_MODE (type, BLKmode);
        if (TYPE_SIZE (type) != 0
index 9739ac855b1eada1d0aad1a08f6989bf77a8aabc..c3dec73ba13c9665d1394862800b5e3ef0f2dfac 100644 (file)
@@ -1,5 +1,7 @@
 2011-03-10  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/template/array22.C: New.
+
        * g++.dg/cpp0x/syntax-err1.C: New.
        * g++.dg/parse/error36.C: Adjust expected errors.
        * g++.old-deja/g++.pt/ctor2.C: Likewise.
diff --git a/gcc/testsuite/g++.dg/template/array22.C b/gcc/testsuite/g++.dg/template/array22.C
new file mode 100644 (file)
index 0000000..e101587
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/48029
+
+template <class T> struct A { };
+template <class T, class U> struct B
+{
+  struct N { };
+  typedef U u;
+};
+
+typedef B<int, A<int>(*)[2]> btype;
+A<int> v1[2];
+btype v2;
+
+
index c947072b215ccd80ff86c1a646277d438b2712d0..2e1b9a308bd19c32b8c5f926dd1cd4763231c0fc 100644 (file)
@@ -5981,12 +5981,19 @@ type_hash_eq (const void *va, const void *vb)
       || TREE_TYPE (a->type) != TREE_TYPE (b->type)
       || !attribute_list_equal (TYPE_ATTRIBUTES (a->type),
                                 TYPE_ATTRIBUTES (b->type))
-      || TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type)
-      || TYPE_MODE (a->type) != TYPE_MODE (b->type)
       || (TREE_CODE (a->type) != COMPLEX_TYPE
           && TYPE_NAME (a->type) != TYPE_NAME (b->type)))
     return 0;
 
+  /* Be careful about comparing arrays before and after the element type
+     has been completed; don't compare TYPE_ALIGN unless both types are
+     complete.  */
+  if (COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (a->type)
+      && COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (b->type)
+      && (TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type)
+         || TYPE_MODE (a->type) != TYPE_MODE (b->type)))
+    return 0;
+
   switch (TREE_CODE (a->type))
     {
     case VOID_TYPE: