aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1996-07-03 17:34:57 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1996-07-03 17:34:57 -0400
commit9753f1136864a98cca12ab71f0ffe1af4dd84486 (patch)
tree3aaa13afd22e76d95ea2fc4fa9591888538ed6f9 /gcc
parent4689ad58a187bc99c5cc2299fdd07bcd3363f09b (diff)
downloadgcc-9753f1136864a98cca12ab71f0ffe1af4dd84486.zip
gcc-9753f1136864a98cca12ab71f0ffe1af4dd84486.tar.gz
gcc-9753f1136864a98cca12ab71f0ffe1af4dd84486.tar.bz2
(default_conversion): Add bitfield promotions.
From-SVN: r12389
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-typeck.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index d2abd72..9960f11 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -1010,6 +1010,24 @@ default_conversion (exp)
return convert (type, exp);
}
+ if (TREE_CODE (exp) == COMPONENT_REF
+ && DECL_BIT_FIELD (TREE_OPERAND (exp, 1)))
+ {
+ tree width = DECL_SIZE (TREE_OPERAND (exp, 1));
+ HOST_WIDE_INT low = TREE_INT_CST_LOW (width);
+
+ /* If it's thinner than an int, promote it like a
+ C_PROMOTING_INTEGER_TYPE_P, otherwise leave it alone. */
+
+ if (low < TYPE_PRECISION (integer_type_node))
+ {
+ if ( flag_traditional && TREE_UNSIGNED (type))
+ return convert (unsigned_type_node, exp);
+ else
+ return convert (integer_type_node, exp);
+ }
+ }
+
if (C_PROMOTING_INTEGER_TYPE_P (type))
{
/* Traditionally, unsignedness is preserved in default promotions.