diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
commit | e252b51ccde010cbd2a146485d8045103cd99533 (patch) | |
tree | e060f101cdc32bf5e520de8e5275db9d4236b74c /gcc/stor-layout.c | |
parent | f10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff) | |
parent | 104c05c5284b7822d770ee51a7d91946c7e56d50 (diff) | |
download | gcc-e252b51ccde010cbd2a146485d8045103cd99533.zip gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2 |
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 784f131..242452f 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2072,16 +2072,24 @@ finish_bitfield_representative (tree repr, tree field) bitsize = (bitsize + BITS_PER_UNIT - 1) & ~(BITS_PER_UNIT - 1); /* Now nothing tells us how to pad out bitsize ... */ - nextf = DECL_CHAIN (field); - while (nextf && TREE_CODE (nextf) != FIELD_DECL) - nextf = DECL_CHAIN (nextf); + if (TREE_CODE (DECL_CONTEXT (field)) == RECORD_TYPE) + { + nextf = DECL_CHAIN (field); + while (nextf && TREE_CODE (nextf) != FIELD_DECL) + nextf = DECL_CHAIN (nextf); + } + else + nextf = NULL_TREE; if (nextf) { tree maxsize; /* If there was an error, the field may be not laid out correctly. Don't bother to do anything. */ if (TREE_TYPE (nextf) == error_mark_node) - return; + { + TREE_TYPE (repr) = error_mark_node; + return; + } maxsize = size_diffop (DECL_FIELD_OFFSET (nextf), DECL_FIELD_OFFSET (repr)); if (tree_fits_uhwi_p (maxsize)) @@ -2167,11 +2175,7 @@ finish_bitfield_layout (tree t) tree field, prev; tree repr = NULL_TREE; - /* Unions would be special, for the ease of type-punning optimizations - we could use the underlying type as hint for the representative - if the bitfield would fit and the representative would not exceed - the union in size. */ - if (TREE_CODE (t) != RECORD_TYPE) + if (TREE_CODE (t) == QUAL_UNION_TYPE) return; for (prev = NULL_TREE, field = TYPE_FIELDS (t); @@ -2233,7 +2237,13 @@ finish_bitfield_layout (tree t) if (repr) DECL_BIT_FIELD_REPRESENTATIVE (field) = repr; - prev = field; + if (TREE_CODE (t) == RECORD_TYPE) + prev = field; + else if (repr) + { + finish_bitfield_representative (repr, field); + repr = NULL_TREE; + } } if (repr) @@ -2838,6 +2848,8 @@ set_min_and_max_values_for_integral_type (tree type, if (precision < 1) return; + gcc_assert (precision <= WIDE_INT_MAX_PRECISION); + TYPE_MIN_VALUE (type) = wide_int_to_tree (type, wi::min_value (precision, sgn)); TYPE_MAX_VALUE (type) |