Skip to content

Commit

Permalink
Allow declarations in case statement
Browse files Browse the repository at this point in the history
This now works:

 case 1:
    int z = 123;
    break;
  • Loading branch information
hermantb committed Jan 16, 2024
1 parent 04365dd commit bbe2e5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tccgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -7266,7 +7266,7 @@ static void block(int is_expr)
if (is_expr) {
vpop();
gexpr();
} else {
} else if (!decl(VT_JMP)) {
gexpr();
vpop();
}
Expand Down
3 changes: 2 additions & 1 deletion tests/tests2/06_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ int main()
break;

case 2:
printf("%d\n", 2);
int a = 2;
printf("%d\n", a);
break;

default:
Expand Down

0 comments on commit bbe2e5a

Please sign in to comment.