flexarray: Accept empty ones
See testcase, it's a GNU extension, but widely accepted (the
linux kernel uses it). This got broken with 72b520e709
.
This commit is contained in:
parent
9712541156
commit
ebb4e71236
2 changed files with 5 additions and 0 deletions
4
tccgen.c
4
tccgen.c
|
@ -7660,6 +7660,10 @@ static void decl_initializer(init_params *p, CType *type, unsigned long c, int f
|
||||||
}
|
}
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
|
/* GNU extension: if the initializer is empty for a flex array,
|
||||||
|
it's size is zero. We won't enter the loop, so set the size
|
||||||
|
now. */
|
||||||
|
decl_design_flex(p, s, len);
|
||||||
while (tok != '}' || (flags & DIF_HAVE_ELEM)) {
|
while (tok != '}' || (flags & DIF_HAVE_ELEM)) {
|
||||||
len = decl_designator(p, type, c, &f, flags, len);
|
len = decl_designator(p, type, c, &f, flags, len);
|
||||||
flags &= ~DIF_HAVE_ELEM;
|
flags &= ~DIF_HAVE_ELEM;
|
||||||
|
|
|
@ -15,6 +15,7 @@ int f1int (void) {
|
||||||
struct wint q = {"bugs"};
|
struct wint q = {"bugs"};
|
||||||
return !s[0];
|
return !s[0];
|
||||||
}
|
}
|
||||||
|
int empty[] = {}; // GNU extension
|
||||||
int main (void) {
|
int main (void) {
|
||||||
char s[9]="nonono";
|
char s[9]="nonono";
|
||||||
static struct wchar q = {"bugs", {'c'}};
|
static struct wchar q = {"bugs", {'c'}};
|
||||||
|
|
Loading…
Reference in a new issue