OSDN Git Service

(default_conversion): Add bitfield promotions.
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 3 Jul 1996 21:34:57 +0000 (21:34 +0000)
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 3 Jul 1996 21:34:57 +0000 (21:34 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@12389 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-typeck.c

index d2abd72..9960f11 100644 (file)
@@ -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.