aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir N. Makarov <vmakarov@cygnus.com>1999-02-08 16:00:46 +0000
committerVladimir Makarov <vmakarov@gcc.gnu.org>1999-02-08 16:00:46 +0000
commit43f7bed5382117d1ad0c0cd11e572697e18fe19d (patch)
tree60dfefde34e222d8b7627ad7d2847648aa63f309
parentef5ae176719e04e4f54bc95cde9447e52af62906 (diff)
downloadgcc-43f7bed5382117d1ad0c0cd11e572697e18fe19d.zip
gcc-43f7bed5382117d1ad0c0cd11e572697e18fe19d.tar.gz
gcc-43f7bed5382117d1ad0c0cd11e572697e18fe19d.tar.bz2
c-typeck.c (check_init_type_bitfields): Use nonincremental initialization of unions whose first member is a bitfield.
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
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/c-typeck.c15
-rw-r--r--gcc/varasm.c6
3 files changed, 27 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 78cb6ae..35680f6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index a167602..c065dc4 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -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));
}
diff --git a/gcc/varasm.c b/gcc/varasm.c
index dc46c98..213c07c 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -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),