re PR c++/65690 (typedef alignment lost since r219705)
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Apr 2015 15:06:56 +0000 (17:06 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 9 Apr 2015 15:06:56 +0000 (17:06 +0200)
PR c++/65690
* tree.c (build_cplus_array_type): Layout type before variants are
set, but copy over TYPE_SIZE and TYPE_SIZE_UNIT from the main
variant.

* c-c++-common/attr-aligned-1.c: New test.

From-SVN: r221952

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog

index b84f33746187c68b3c3bfc6747f00a170f9b5da6..065cd75f3589effd931c8593751a9cde6aa9b754 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/65690
+       * tree.c (build_cplus_array_type): Layout type before variants are
+       set, but copy over TYPE_SIZE and TYPE_SIZE_UNIT from the main
+       variant.
+
 2015-04-03  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/64085
index 97bccc034038c855ab0d48c541f4a78437c3b999..6802909a2bff835f3f4cb3ecd6997460fadc3418 100644 (file)
@@ -880,12 +880,19 @@ build_cplus_array_type (tree elt_type, tree index_type)
        {
          t = build_min_array_type (elt_type, index_type);
          set_array_type_canon (t, elt_type, index_type);
+         if (!dependent)
+           {
+             layout_type (t);
+             /* Make sure sizes are shared with the main variant.
+                layout_type can't be called after setting TYPE_NEXT_VARIANT,
+                as it will overwrite alignment etc. of all variants.  */
+             TYPE_SIZE (t) = TYPE_SIZE (m);
+             TYPE_SIZE_UNIT (t) = TYPE_SIZE_UNIT (m);
+           }
 
          TYPE_MAIN_VARIANT (t) = m;
          TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
          TYPE_NEXT_VARIANT (m) = t;
-         if (!dependent)
-           layout_type (t);
        }
     }
 
index 90e467abb41cdea6e99529e031aff25d6054f82a..710e299bbf094294423f016d707ab95a8eac692b 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/65690
+       * c-c++-common/attr-aligned-1.c: New test.
+
 2015-04-09  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        * gcc.target/i386/mpx/memmove-zero-length.c: New.