History

flexarray: Accept empty ones

See testcase, it's a GNU extension, but widely accepted (the linux kernel uses it). This got broken with 72b520e709d.

Michael Matz committed 4 years ago

Commit ebb4e711 parent 97125412 files · +5 −0Browse files

Unified · Split

2 files
  1. tccgen.c +4 −0
  2. tests/tests2/80_flexarray.c +1 −0
tccgen.c+4−0
@@ -7660,6 +7660,10 @@ static void decl_initializer(init_params *p, CType *type, unsigned long c, int f · 7659 unmodified lines
7660 }7660 }
7661 7661
7662 len = 0;7662 len = 0;
7663 /* GNU extension: if the initializer is empty for a flex array,
7664 it's size is zero. We won't enter the loop, so set the size
7665 now. */
7666 decl_design_flex(p, s, len);
7663 while (tok != '}' || (flags & DIF_HAVE_ELEM)) {7667 while (tok != '}' || (flags & DIF_HAVE_ELEM)) {
7664 len = decl_designator(p, type, c, &f, flags, len);7668 len = decl_designator(p, type, c, &f, flags, len);
7665 flags &= ~DIF_HAVE_ELEM;7669 flags &= ~DIF_HAVE_ELEM;
tests/tests2/80_flexarray.c+1−0
@@ -15,6 +15,7 @@ int f1int (void) { · 14 unmodified lines
15 struct wint q = {"bugs"};15 struct wint q = {"bugs"};
16 return !s[0];16 return !s[0];
17}17}
18int empty[] = {}; // GNU extension
18int main (void) {19int main (void) {
19 char s[9]="nonono";20 char s[9]="nonono";
20 static struct wchar q = {"bugs", {'c'}};21 static struct wchar q = {"bugs", {'c'}};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t