From: hubicka Date: Wed, 7 Nov 2018 12:25:35 +0000 (+0000) Subject: * tree.c (fld_type_variant_equal_p): Skip TYPE_ALIGN check when X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd82677411e557b3df1ba98ff39ea0d400a4d92c;p=thirdparty%2Fgcc.git * tree.c (fld_type_variant_equal_p): Skip TYPE_ALIGN check when building incomplete variant of complete type. (fld_type_variant): Do not copy TYPE_ALIGN when building incomplete variant of complete type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265872 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d2e167b5ca27..f8295d5e86f9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-11-07 Jan Hubicka + + * tree.c (fld_type_variant_equal_p): Skip TYPE_ALIGN check when + building incomplete variant of complete type. + (fld_type_variant): Do not copy TYPE_ALIGN when building incomplete + variant of complete type. + 2018-11-07 Chenghua Xu * config/mips/mips.c: Fix typo in documentation of diff --git a/gcc/tree.c b/gcc/tree.c index 143608649c09..b1f4ecf5db9f 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -5106,12 +5106,15 @@ static bool fld_type_variant_equal_p (tree t, tree v) { if (TYPE_QUALS (t) != TYPE_QUALS (v) - || TYPE_ALIGN (t) != TYPE_ALIGN (v) + /* We want to match incomplete variants with complete types. + In this case we need to ignore alignment. */ + || ((!RECORD_OR_UNION_TYPE_P (t) || COMPLETE_TYPE_P (v)) + && TYPE_ALIGN (t) != TYPE_ALIGN (v)) || fld_simplified_type_name (t) != fld_simplified_type_name (v) || !attribute_list_equal (TYPE_ATTRIBUTES (t), TYPE_ATTRIBUTES (v))) return false; - + return true; } @@ -5134,7 +5137,10 @@ fld_type_variant (tree first, tree t, struct free_lang_data_d *fld) TYPE_NAME (v) = TYPE_NAME (t); TYPE_ATTRIBUTES (v) = TYPE_ATTRIBUTES (t); TYPE_CANONICAL (v) = TYPE_CANONICAL (t); - SET_TYPE_ALIGN (v, TYPE_ALIGN (t)); + /* Variants of incomplete types should have alignment + set to BITS_PER_UNIT. Do not copy the actual alignment. */ + if (!RECORD_OR_UNION_TYPE_P (v) || COMPLETE_TYPE_P (v)) + SET_TYPE_ALIGN (v, TYPE_ALIGN (t)); gcc_checking_assert (fld_type_variant_equal_p (t,v)); add_tree_to_fld_list (v, fld); return v;