]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/53989 (Internal compiler error in strip_typedefs, at cp/tree.c:1187)
authorJason Merrill <jason@redhat.com>
Tue, 17 Jul 2012 21:34:06 +0000 (17:34 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 17 Jul 2012 21:34:06 +0000 (17:34 -0400)
PR c++/53989
* tree.c (build_cplus_array_type): Also add TYPE_CANONICAL
to the list of variants.

From-SVN: r189587

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/array23.C [new file with mode: 0644]

index 3325f1a12e1df5c88f27478f87d70bd38807e2b7..c1465ccc385d4d2c704e061ef19ba1ef002b9376 100644 (file)
@@ -1,5 +1,9 @@
 2012-07-17  Jason Merrill  <jason@redhat.com>
 
+       PR c++/53989
+       * tree.c (build_cplus_array_type): Also add TYPE_CANONICAL
+       to the list of variants.
+
        * decl.c (xref_basetypes): Complain about incomplete template base.
        * class.c (finish_struct): Adjust variants in templates, too.
 
index 01bc48383b45d11ec018c18ff26e9e5d3fc8cee1..3c7bbb132f31674c155bc33d76b13f7ce8622d13 100644 (file)
@@ -803,12 +803,23 @@ build_cplus_array_type (tree elt_type, tree index_type)
     {
       tree m = build_cplus_array_type (TYPE_MAIN_VARIANT (elt_type),
                                       index_type);
+      tree c = TYPE_CANONICAL (t);
+
       if (TYPE_MAIN_VARIANT (t) != m)
        {
          TYPE_MAIN_VARIANT (t) = m;
          TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
          TYPE_NEXT_VARIANT (m) = t;
        }
+
+      /* If we built a new array type for TYPE_CANONICAL, add
+        that to the list of variants as well.  */
+      if (c && c != t && TYPE_MAIN_VARIANT (c) != m)
+       {
+         TYPE_MAIN_VARIANT (c) = m;
+         TYPE_NEXT_VARIANT (c) = t;
+         TYPE_NEXT_VARIANT (m) = c;
+       }
     }
 
   /* Push these needs up so that initialization takes place
index 70efda9ed5dda0f332e10f97d4f47a2295b70cea..5784918c8d1ba20e641cfb5e7fcd5b7b91d11e96 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-17  Jason Merrill  <jason@redhat.com>
+
+       PR c++/53989
+       * g++.dg/template/array23.C: New.
+
 2012-07-17  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/53985
diff --git a/gcc/testsuite/g++.dg/template/array23.C b/gcc/testsuite/g++.dg/template/array23.C
new file mode 100644 (file)
index 0000000..6ede8b0
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/53989
+
+struct Foo {
+  int value;
+  typedef Foo Foo2;
+  static Foo2 const foos[2];
+};
+
+template <class T> void g (T);
+void bar() {
+  g(&Foo::foos);
+}