History

Accept empty struct member decls

struct S { /*nothing*/; int a; }; is an acceptable struct declaration, there may be stray semicolons in the member list.

Michael Matz committed 10 years ago

Commit 6763b021 parent d5d881d2 files · +9 −1Browse files

Unified · Split

2 files
  1. tccgen.c +4 −1
  2. tests/tcctest.c +5 −0
tccgen.c+4−1
@@ -3250,7 +3250,10 @@ static void struct_decl(CType *type, AttributeDef *ad, int u) · 3249 unmodified lines
32503250 offset = 0;
32513251 flexible = 0;
32523252 while (tok != '}') {
3253− parse_btype(&btype, &ad1);
3253+ if (!parse_btype(&btype, &ad1)) {
3254+ skip(';');
3255+ continue;
3256+ }
32543257 while (1) {
32553258 extra_bytes = 0;
32563259 if (flexible)
tests/tcctest.c+5−0
@@ -642,6 +642,11 @@ union union2 { · 641 unmodified lines
642642
643643 struct struct1 st1, st2;
644644
645+struct empty_mem {
646+ /* nothing */ ;
647+ int x;
648+};
649+
645650 int main(int argc, char **argv)
646651 {
647652 string_test();

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