From 43f7bed5382117d1ad0c0cd11e572697e18fe19d Mon Sep 17 00:00:00 2001 From: "Vladimir N. Makarov" Date: Mon, 8 Feb 1999 16:00:46 +0000 Subject: [PATCH] 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 * 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 | 10 ++++++++++ gcc/c-typeck.c | 15 ++++++++++++--- gcc/varasm.c | 6 +++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 78cb6ae43ec..35680f61784 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +Mon Feb 9 18:57:45 1999 Vladimir N. Makarov + + * 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 * config/c4x/c4x.md (*movhi_stik): New pattern. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index a16760282b4..c065dc4f909 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 dc46c98899c..213c07c9a58 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), -- 2.30.2