From bbe2e5a421e0bcc5f386302e5120e1de60f01407 Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Tue, 16 Jan 2024 07:51:56 +0100 Subject: [PATCH] Allow declarations in case statement This now works: case 1: int z = 123; break; --- tccgen.c | 2 +- tests/tests2/06_case.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tccgen.c b/tccgen.c index 602afa3fb..d5e9bf515 100644 --- a/tccgen.c +++ b/tccgen.c @@ -7266,7 +7266,7 @@ static void block(int is_expr) if (is_expr) { vpop(); gexpr(); - } else { + } else if (!decl(VT_JMP)) { gexpr(); vpop(); } diff --git a/tests/tests2/06_case.c b/tests/tests2/06_case.c index c0191e2b0..75b8d45d6 100644 --- a/tests/tests2/06_case.c +++ b/tests/tests2/06_case.c @@ -14,7 +14,8 @@ int main() break; case 2: - printf("%d\n", 2); + int a = 2; + printf("%d\n", a); break; default: