aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-05-03 17:57:08 +0900
committernsfisis <nsfisis@gmail.com>2025-05-03 17:57:08 +0900
commit79e00de77709e1a8a9a12939c59606e38b27e52f (patch)
tree3cc4c38a513800c0829c5708dc6911417957b309
parentfa1b51ea49e2902fcf778c2547f9f332640320f1 (diff)
downloadP4Dcc-79e00de77709e1a8a9a12939c59606e38b27e52f.tar.gz
P4Dcc-79e00de77709e1a8a9a12939c59606e38b27e52f.tar.zst
P4Dcc-79e00de77709e1a8a9a12939c59606e38b27e52f.zip
fix code generation failure if "if" stmt has no "else" clause
-rw-r--r--main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/main.c b/main.c
index 7670a08..7298d56 100644
--- a/main.c
+++ b/main.c
@@ -841,7 +841,9 @@ void gen_if_stmt(CODEGEN* g, AST* ast) {
gen_stmt(g, ast->node1);
printf(" jmp .Lend%d\n", label);
printf(".Lelse%d:\n", label);
- gen_stmt(g, ast->node2);
+ if (ast->node2) {
+ gen_stmt(g, ast->node2);
+ }
printf(".Lend%d:\n", label);
}