Commit 06038f12 by Richard Stallman

(finish_struct): Promote unsigned bitfield to signed int

if the field isn't as wide as an int.

From-SVN: r4178
parent 1815bfc2
...@@ -5260,15 +5260,19 @@ finish_struct (t, fieldlist) ...@@ -5260,15 +5260,19 @@ finish_struct (t, fieldlist)
/* Promote each bit-field's type to int if it is narrower than that. */ /* Promote each bit-field's type to int if it is narrower than that. */
for (x = fieldlist; x; x = TREE_CHAIN (x)) for (x = fieldlist; x; x = TREE_CHAIN (x))
if (DECL_BIT_FIELD (x) if (DECL_BIT_FIELD (x)
&& C_PROMOTING_INTEGER_TYPE_P (TREE_TYPE (x))) && (C_PROMOTING_INTEGER_TYPE_P (TREE_TYPE (x))
|| DECL_FIELD_SIZE (x) < TYPE_PRECISION (integer_type_node)))
{ {
tree type = TREE_TYPE (x); tree type = TREE_TYPE (x);
/* Preserve unsignedness if traditional or if not really any wider. */ /* Preserve unsignedness if traditional
or if not really getting any wider. */
if (TREE_UNSIGNED (type) if (TREE_UNSIGNED (type)
&& (flag_traditional && (flag_traditional
|| (TYPE_PRECISION (type) ||
== TYPE_PRECISION (integer_type_node)))) (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)
&&
DECL_FIELD_SIZE (x) == TYPE_PRECISION (integer_type_node))))
TREE_TYPE (x) = unsigned_type_node; TREE_TYPE (x) = unsigned_type_node;
else else
TREE_TYPE (x) = integer_type_node; TREE_TYPE (x) = integer_type_node;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment