Skip to content

Commit 6fe2da9

Browse files
Jan HubickaJan Hubicka
authored andcommitted
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
1 parent f70b5db commit 6fe2da9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

gcc/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2018-11-07 Jan Hubicka <[email protected]>
2+
3+
* tree.c (fld_type_variant_equal_p): Skip TYPE_ALIGN check when
4+
building incomplete variant of complete type.
5+
(fld_type_variant): Do not copy TYPE_ALIGN when building incomplete
6+
variant of complete type.
7+
18
2018-11-07 Chenghua Xu <[email protected]>
29

310
* config/mips/mips.c: Fix typo in documentation of

gcc/tree.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5106,12 +5106,15 @@ static bool
51065106
fld_type_variant_equal_p (tree t, tree v)
51075107
{
51085108
if (TYPE_QUALS (t) != TYPE_QUALS (v)
5109-
|| TYPE_ALIGN (t) != TYPE_ALIGN (v)
5109+
/* We want to match incomplete variants with complete types.
5110+
In this case we need to ignore alignment. */
5111+
|| ((!RECORD_OR_UNION_TYPE_P (t) || COMPLETE_TYPE_P (v))
5112+
&& TYPE_ALIGN (t) != TYPE_ALIGN (v))
51105113
|| fld_simplified_type_name (t) != fld_simplified_type_name (v)
51115114
|| !attribute_list_equal (TYPE_ATTRIBUTES (t),
51125115
TYPE_ATTRIBUTES (v)))
51135116
return false;
5114-
5117+
51155118
return true;
51165119
}
51175120

@@ -5134,7 +5137,10 @@ fld_type_variant (tree first, tree t, struct free_lang_data_d *fld)
51345137
TYPE_NAME (v) = TYPE_NAME (t);
51355138
TYPE_ATTRIBUTES (v) = TYPE_ATTRIBUTES (t);
51365139
TYPE_CANONICAL (v) = TYPE_CANONICAL (t);
5137-
SET_TYPE_ALIGN (v, TYPE_ALIGN (t));
5140+
/* Variants of incomplete types should have alignment
5141+
set to BITS_PER_UNIT. Do not copy the actual alignment. */
5142+
if (!RECORD_OR_UNION_TYPE_P (v) || COMPLETE_TYPE_P (v))
5143+
SET_TYPE_ALIGN (v, TYPE_ALIGN (t));
51385144
gcc_checking_assert (fld_type_variant_equal_p (t,v));
51395145
add_tree_to_fld_list (v, fld);
51405146
return v;

0 commit comments

Comments
 (0)