boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

commit 8755ab3a67b482d417439ec467f2c6babda7dcab
parent 9c40bcc14c1d4d7eed39d4da9dbe8fc53006a1c2
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Sun, 26 Apr 2026 22:33:18 -0700

cc/parse: real goto + labelled-stmt via cg-goto/cg-emit-label (§F.4)

parse-goto-stmt previously emitted cg-break with a "user_<name>" tag,
which routed through libp1pp's loop-tag namespace — wrong for C goto.
Now emits cg-goto for proper unconditional jumps.

parse-labelled-stmt previously consumed `IDENT :` and emitted nothing.
Now drops cg-emit-label so jumps to that name actually land.

Diffstat:
Mcc/parse.scm | 8+++++---
Atests/cc-parse/66-goto.c | 11+++++++++++
Atests/cc-parse/66-goto.expected-exit | 1+
3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/cc/parse.scm b/cc/parse.scm @@ -635,13 +635,15 @@ (expect-kw ps 'goto) (let ((t (advance ps))) (cond ((eq? (tok-kind t) 'IDENT) - (cg-break (ps-cg ps) - (bytevector-append "user_" (tok-value t)))) + (cg-goto (ps-cg ps) (tok-value t))) (else (die (tok-loc t) "label?")))) (expect-punct ps 'semi)) (define (parse-labelled-stmt ps) - (advance ps) (expect-punct ps 'colon) (parse-stmt ps)) + (let ((t (advance ps))) + (expect-punct ps 'colon) + (cg-emit-label (ps-cg ps) (tok-value t)) + (parse-stmt ps))) (define (parse-expr-stmt ps) (cond diff --git a/tests/cc-parse/66-goto.c b/tests/cc-parse/66-goto.c @@ -0,0 +1,11 @@ +int main(void) { + int s; int i; + s = 0; i = 0; +loop: + if (i >= 3) goto done; + s = s + 1; + i = i + 1; + goto loop; +done: + return s; /* 3 */ +} diff --git a/tests/cc-parse/66-goto.expected-exit b/tests/cc-parse/66-goto.expected-exit @@ -0,0 +1 @@ +3