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
76607660 }
76617661
76627662 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);
76637667 while (tok != '}' || (flags & DIF_HAVE_ELEM)) {
76647668 len = decl_designator(p, type, c, &f, flags, len);
76657669 flags &= ~DIF_HAVE_ELEM;
tests/tests2/80_flexarray.c+1−0
@@ -15,6 +15,7 @@ int f1int (void) { · 14 unmodified lines
1515 struct wint q = {"bugs"};
1616 return !s[0];
1717 }
18+int empty[] = {}; // GNU extension
1819 int main (void) {
1920 char s[9]="nonono";
2021 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