Skip to content

Commit b56cb69

Browse files
authored
Merge pull request diffblue#5603 from tautschnig/anonymous-members
C front-end: anonymous struct/union members need not be of struct/union type
2 parents dcf92fe + f9c7e22 commit b56cb69

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
struct S
2+
{
3+
struct
4+
{
5+
int : 1;
6+
int;
7+
int named;
8+
};
9+
};
10+
11+
struct S s = {.named = 0};
12+
13+
int main()
14+
{
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

src/ansi-c/anonymous_member.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ bool has_component_rec(
8888
{
8989
return true;
9090
}
91-
else if(comp.get_anonymous())
91+
else if(
92+
comp.get_anonymous() &&
93+
(comp.type().id() == ID_struct_tag || comp.type().id() == ID_union_tag))
9294
{
9395
if(has_component_rec(comp.type(), component_name, ns))
9496
return true;

0 commit comments

Comments
 (0)