]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/48029 (ICE in finish_member_declaration() with --param ggc-min-expand=0...
authorJason Merrill <jason@redhat.com>
Fri, 11 Mar 2011 17:20:27 +0000 (12:20 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 11 Mar 2011 17:20:27 +0000 (12:20 -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: r170880

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 76879501729560c8f749f43f7b27b0c7f567399d..7380093e91bfa9ab539c0aa45ea0658b0a1b6367 100644 (file)
@@ -1,3 +1,10 @@
+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-08  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline
index 337e94bd556c31fb9e8138aba957b48608123e45..7116382256692f7256e70a5c5b21af4e090d14e3 100644 (file)
@@ -1,3 +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.
+
 2011-03-09  Jason Merrill  <jason@redhat.com>
 
        PR c++/44629
index b868770007b9461639bb5149b86e5d1ebc16270c..847712bfb03902d4bc4b670d425038808138f5de 100644 (file)
@@ -1556,13 +1556,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 55e3403b19f2ece1c6a32fb5e34577afc7b74c1a..718161d69034848d130bac716741c91b515cbbd3 100644 (file)
@@ -2029,11 +2029,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 feb556bae42be3df8f5312868066fc175d146805..a1128bc38008af68c5fa5abd2bf6119377500f2b 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-10  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/template/array22.C: New.
+
 2011-03-11  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/47278
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 05218a05d0f937f405859bb6e0959239d9207f5b..4b1bfac42ae9c4256e882584e1e6b9ebc2bc56a9 100644 (file)
@@ -5797,12 +5797,18 @@ 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_TYPE_P (a->type) && COMPLETE_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: