OSDN Git Service

PR c++/53989
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 17 Jul 2012 21:34:22 +0000 (21:34 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 17 Jul 2012 21:34:22 +0000 (21:34 +0000)
* tree.c (build_cplus_array_type): Also add TYPE_CANONICAL
to the list of variants.

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

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

index d1003d4..9daf2e0 100644 (file)
@@ -1,5 +1,11 @@
 2012-07-17  Jason Merrill  <jason@redhat.com>
 
 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.
+
+2012-07-17  Jason Merrill  <jason@redhat.com>
+
        PR c++/53549
        * parser.c (cp_parser_class_head): Call xref_basetypes here.
        (cp_parser_class_specifier_1): Not here.
        PR c++/53549
        * parser.c (cp_parser_class_head): Call xref_basetypes here.
        (cp_parser_class_specifier_1): Not here.
index 0d47578..1e98f85 100644 (file)
@@ -794,12 +794,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 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 (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
     }
 
   /* Push these needs up so that initialization takes place
index 5a8fdea..886661c 100644 (file)
@@ -1,5 +1,10 @@
 2012-07-17  Jason Merrill  <jason@redhat.com>
 
 2012-07-17  Jason Merrill  <jason@redhat.com>
 
+       PR c++/53989
+       * g++.dg/template/array23.C: New.
+
+2012-07-17  Jason Merrill  <jason@redhat.com>
+
        PR c++/53549
        * g++.dg/template/current-inst1.C: New.
        * g++.dg/parse/crash35.C: Adjust.
        PR c++/53549
        * g++.dg/template/current-inst1.C: New.
        * g++.dg/parse/crash35.C: Adjust.
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);
+}