fix anonymous struct member initialization
The C front-end needs to ignore the unnamed bit-field during struct initialization; issue #3709.
This commit is contained in:
parent
54198943e7
commit
4548fc1907
|
@ -3,7 +3,9 @@
|
|||
struct tag1 {
|
||||
int f;
|
||||
int : 32; // unnamed bit-field, ignored during initialization
|
||||
int g;
|
||||
union {
|
||||
int g;
|
||||
}; // anonymous, but not ignored
|
||||
int *p;
|
||||
int a[2];
|
||||
} x;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
KNOWNBUG
|
||||
CORE
|
||||
main.c
|
||||
|
||||
^EXIT=0$
|
||||
|
|
|
@ -665,10 +665,16 @@ void c_typecheck_baset::increment_designator(designatort &designator)
|
|||
assert(components.size()==entry.size);
|
||||
|
||||
// we skip over any padding or code
|
||||
while(entry.index<entry.size &&
|
||||
// we also skip over anonymous members
|
||||
while(entry.index < entry.size &&
|
||||
(components[entry.index].get_is_padding() ||
|
||||
components[entry.index].type().id()==ID_code))
|
||||
(components[entry.index].get_anonymous() &&
|
||||
components[entry.index].type().id() != ID_struct_tag &&
|
||||
components[entry.index].type().id() != ID_union_tag) ||
|
||||
components[entry.index].type().id() == ID_code))
|
||||
{
|
||||
entry.index++;
|
||||
}
|
||||
|
||||
if(entry.index<entry.size)
|
||||
entry.subtype=components[entry.index].type();
|
||||
|
|
Loading…
Reference in New Issue