c-typeck.c (check_init_type_bitfields): Use nonincremental initialization of unions...
authorVladimir N. Makarov <vmakarov@cygnus.com>
Mon, 8 Feb 1999 16:00:46 +0000 (16:00 +0000)
committerVladimir Makarov <vmakarov@gcc.gnu.org>
Mon, 8 Feb 1999 16:00:46 +0000 (16:00 +0000)
Mon Feb  9 18:57:45 1999  Vladimir N. Makarov  <vmakarov@cygnus.com>
* c-typeck.c (check_init_type_bitfields): Use nonincremental
initialization of unions whose first member is a bitfield.
        Remove unnecessary code for checking the declaration mode
        after DECL_C_BIT_FIELD.
* varasm.c (output_constructor): Additional comment about the
  constructor of bitfield union initialization.

From-SVN: r25093

gcc/ChangeLog
gcc/c-typeck.c
gcc/varasm.c

index 78cb6ae43ec3d042474631b8ff5e81be3b344101..35680f61784c04839363347e6c37c68f1831152f 100644 (file)
@@ -1,3 +1,13 @@
+Mon Feb  9 18:57:45 1999  Vladimir N. Makarov  <vmakarov@cygnus.com>
+
+       * c-typeck.c (check_init_type_bitfields): Use nonincremental
+       initialization of unions whose first member is a bitfield.
+        Remove unnecessary code for checking the declaration mode
+        after DECL_C_BIT_FIELD.
+
+       * varasm.c (output_constructor): Additional comment about the
+       constructor of bitfield union initialization.
+
 Tue Feb  9 11:55:04 1999  Michael Hayes  <m.hayes@elec.canterbury.ac.nz>
 
        * config/c4x/c4x.md (*movhi_stik): New pattern.
index a16760282b4cf8e9348e99563d313f0f08dc0716..c065dc4f909babde84ba91a55b0f01d0c43f05c3 100644 (file)
@@ -5480,9 +5480,7 @@ check_init_type_bitfields (type)
       for (tail = TYPE_FIELDS (type); tail;
           tail = TREE_CHAIN (tail))
        {
-         if (DECL_C_BIT_FIELD (tail)
-             /* This catches cases like `int foo : 8;'.  */
-             || DECL_MODE (tail) != TYPE_MODE (TREE_TYPE (tail)))
+         if (DECL_C_BIT_FIELD (tail))
            {
              constructor_incremental = 0;
              break;
@@ -5492,6 +5490,17 @@ check_init_type_bitfields (type)
        }
     }
 
+  else if (TREE_CODE (type) == UNION_TYPE)
+    {
+      tree tail = TYPE_FIELDS (type);
+      if (tail && DECL_C_BIT_FIELD (tail))
+       /* We also use the nonincremental algorithm for initiliazation
+          of unions whose first member is a bitfield, becuase the
+          incremental algorithm has no code for dealing with
+          bitfields. */
+       constructor_incremental = 0;
+    }
+
   else if (TREE_CODE (type) == ARRAY_TYPE)
     check_init_type_bitfields (TREE_TYPE (type));
 }
index dc46c98899c3b004df62eba988fdf15b2f606bbd..213c07c9a582066bfea5480483ebc42daf60401e 100644 (file)
@@ -3998,7 +3998,11 @@ output_constructor (exp, size)
      FIELD goes through the structure fields, if the constant is a structure.
      if the constant is a union, then we override this,
      by getting the field from the TREE_LIST element.
-     But the constant could also be an array.  Then FIELD is zero.  */
+     But the constant could also be an array.  Then FIELD is zero.
+
+     There is always a maximum of one element in the chain LINK for unions
+     (even if the initializer in a source program incorrectly contains
+     more one). */
   for (link = CONSTRUCTOR_ELTS (exp);
        link;
        link = TREE_CHAIN (link),