Fixed the bug that a union type containing a struct with a flexible array member was accepted as a struct member or array element type.

This commit is contained in:
acqn
2023-10-27 23:46:10 +08:00
parent 85e63e99a6
commit 8e45a4c960
4 changed files with 49 additions and 10 deletions

31
test/val/fam.c Normal file
View File

@@ -0,0 +1,31 @@
/* Bug #2016 and #2017 - flexible array members */
typedef struct {
int a;
int b[]; /* Ok: Flexible array member can be last */
} X;
typedef union {
X x; /* Ok: Contains flexible array member */
int a;
} U;
typedef struct {
struct {
int a;
};
int b[]; /* Ok: Flexible array member can be last */
} Y;
X x;
U u;
Y y;
_Static_assert(sizeof x == sizeof (int), "sizeof x != sizeof (int)");
_Static_assert(sizeof u == sizeof (int), "sizeof u != sizeof (int)");
_Static_assert(sizeof y == sizeof (int), "sizeof y != sizeof (int)");
int main(void)
{
return 0;
}