From ca0a6a0f84a7cfffca2b3dae172ef1415e8ff96c Mon Sep 17 00:00:00 2001 From: jakub Date: Thu, 9 Apr 2015 15:06:56 +0000 Subject: 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221952 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') 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); } } -- cgit v1.2.1 From 014e7d42f36ef2f645e9e581e72705ea7e50a4e1 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 9 Apr 2015 20:11:44 +0000 Subject: PR c++/65690 * tree.c (cp_build_qualified_type_real): Copy TYPE_ALIGN and TYPE_USER_ALIGN. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221960 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 6802909a2bf..71c84ae38ef 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1079,6 +1079,8 @@ cp_build_qualified_type_real (tree type, { t = build_variant_type_copy (t); TYPE_NAME (t) = TYPE_NAME (type); + TYPE_ALIGN (t) = TYPE_ALIGN (type); + TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (type); } } -- cgit v1.2.1