From 00da5e285de9a4412a9ed6e73668234fa84e17fa Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 9 Apr 2015 17:06:56 +0200 Subject: [PATCH] re PR c++/65690 (typedef alignment lost since r219705) 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 | 7 +++++++ gcc/cp/tree.c | 11 +++++++++-- gcc/testsuite/ChangeLog | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b84f3374618..065cd75f358 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2015-04-09 Jakub Jelinek + + 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 PR c++/64085 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 97bccc03403..6802909a2bf 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 90e467abb41..710e299bbf0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-04-09 Jakub Jelinek + + PR c++/65690 + * c-c++-common/attr-aligned-1.c: New test. + 2015-04-09 Ilya Enkovich * gcc.target/i386/mpx/memmove-zero-length.c: New. -- 2.30.2