aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-04-18 03:35:35 +0000
committerRichard Stallman <rms@gnu.org>1993-04-18 03:35:35 +0000
commit06038f12649f917c9a4d936ebd725fec53962092 (patch)
treed4ecbbc78c21d45b2cd261d7868d32cbe8e9f6f2
parent1815bfc25fbf311268c47ad1b19b1c0bbef7922d (diff)
downloadgcc-06038f12649f917c9a4d936ebd725fec53962092.zip
gcc-06038f12649f917c9a4d936ebd725fec53962092.tar.gz
gcc-06038f12649f917c9a4d936ebd725fec53962092.tar.bz2
(finish_struct): Promote unsigned bitfield to signed int
if the field isn't as wide as an int. From-SVN: r4178
-rw-r--r--gcc/c-decl.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index fefce72..9efece4 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -5260,19 +5260,23 @@ finish_struct (t, fieldlist)
/* Promote each bit-field's type to int if it is narrower than that. */
for (x = fieldlist; x; x = TREE_CHAIN (x))
if (DECL_BIT_FIELD (x)
- && C_PROMOTING_INTEGER_TYPE_P (TREE_TYPE (x)))
- {
- tree type = TREE_TYPE (x);
-
- /* Preserve unsignedness if traditional or if not really any wider. */
- if (TREE_UNSIGNED (type)
- && (flag_traditional
- || (TYPE_PRECISION (type)
- == TYPE_PRECISION (integer_type_node))))
- TREE_TYPE (x) = unsigned_type_node;
- else
- TREE_TYPE (x) = integer_type_node;
- }
+ && (C_PROMOTING_INTEGER_TYPE_P (TREE_TYPE (x))
+ || DECL_FIELD_SIZE (x) < TYPE_PRECISION (integer_type_node)))
+ {
+ tree type = TREE_TYPE (x);
+
+ /* Preserve unsignedness if traditional
+ or if not really getting any wider. */
+ if (TREE_UNSIGNED (type)
+ && (flag_traditional
+ ||
+ (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)
+ &&
+ DECL_FIELD_SIZE (x) == TYPE_PRECISION (integer_type_node))))
+ TREE_TYPE (x) = unsigned_type_node;
+ else
+ TREE_TYPE (x) = integer_type_node;
+ }
/* If this structure or union completes the type of any previous
variable declaration, lay it out and output its rtl. */