commit 74119bd8d7b2d8a91b2b2e5bd7984ce5377402ab
parent 47b81d4c6f906155f23054757a85c829aff80c40
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Fri, 29 May 2026 13:16:32 +0200
cc2/qbe: Emit an initial body label
This label is needed because otherwise branching to the label at
the beginning og the function generates an error in qbe:
invalid jump to the start block
Diffstat:
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/cmd/scc-cc/cc2/qbe/code.c b/src/cmd/scc-cc/cc2/qbe/code.c
@@ -424,7 +424,9 @@ writeout(void)
(p->type.flags & AGGRF) ? "" : ".val");
sep = ",";
}
- printf("%s)\n{\n", (curfun->type.flags&ELLIPS) ? ", ..." : "");
+ printf("%s)\n{\n@%s.body\n",
+ (curfun->type.flags&ELLIPS) ? ", ..." : "",
+ curfun->name);
/* emit assembler instructions */
for (pc = prog; pc; pc = pc->next) {
diff --git a/tests/cc/execute/0274-loop.c b/tests/cc/execute/0274-loop.c
@@ -0,0 +1,8 @@
+int
+main()
+{
+ do {
+ } while (0);
+
+ return 0;
+}
diff --git a/tests/cc/execute/scc-tests.lst b/tests/cc/execute/scc-tests.lst
@@ -264,3 +264,4 @@
0271-struct.c
0272-div.c
0273-cpp.c
+0274-loop.c