diff options
author | Jan Hubicka <jh@suse.cz> | 2018-11-07 13:25:35 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2018-11-07 12:25:35 +0000 |
commit | 6fe2da9fafe878a361e2d23821d590fd53ef99bd (patch) | |
tree | e41f801007654b326ab01c7be0297cea99e0033b | |
parent | f70b5dbfa111f03dd31a3e3bd2e3d01eecdc06c3 (diff) | |
download | gcc-6fe2da9fafe878a361e2d23821d590fd53ef99bd.zip gcc-6fe2da9fafe878a361e2d23821d590fd53ef99bd.tar.gz gcc-6fe2da9fafe878a361e2d23821d590fd53ef99bd.tar.bz2 |
tree.c (fld_type_variant_equal_p): Skip TYPE_ALIGN check when building incomplete variant of complete type.
* 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.
From-SVN: r265872
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/tree.c | 12 |
2 files changed, 16 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d2e167b..f8295d5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-11-07 Jan Hubicka <jh@suse.cz> + + * 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 <paul.hua.gm@gmail.com> * config/mips/mips.c: Fix typo in documentation of @@ -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; |