diff options
| author | 2026-10-14 19:55:03 +0330 | |
|---|---|---|
| committer | 2026-10-14 19:55:03 +0330 | |
| commit | 35d1811c7ef8e41baddb9ce0fbb1d28970ddc213 (patch) | |
| tree | 387fbb068b0e47129e6faea30c7d0b5451921ca8 /src/compiler | |
| parent | merge work/exactsize: exact-size heap bounds (diff) | |
zy: nonzero exit on compile errors
Diffstat (limited to 'src/compiler')
| -rw-r--r-- | src/compiler/base.zc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compiler/base.zc b/src/compiler/base.zc index 8c13201..c6abad7 100644 --- a/src/compiler/base.zc +++ b/src/compiler/base.zc @@ -537,24 +537,26 @@ int errat() { nerr++; return 0; } +// stop with exit status 1 after compile errors (a runtime trap keeps rt.halt). +int errexit() { rt.syscall(rt.SYS_EXIT, 1, 0, 0); return 0; } // finish an error line; the compiler stops after 20 errors. int errend() { if (cmode) { dg_close(); if (nerr >= 20) chkabort = 1; return 0; } rt.put_c(10); - if (nerr >= 20) { rt.put_s("zc: too many errors, stopping\n"); rt.halt(); } + if (nerr >= 20) { rt.put_s("zc: too many errors, stopping\n"); errexit(); } return 0; } // stop compiling after errors and report how many there were. int giveup() { if (cmode) { dg_close(); chkabort = 1; return 0; } - rt.put_s("zc: "); rt.put_n(nerr); if (nerr == 1) rt.put_s(" error\n"); else rt.put_s(" errors\n"); rt.halt(); + rt.put_s("zc: "); rt.put_n(nerr); if (nerr == 1) rt.put_s(" error\n"); else rt.put_s(" errors\n"); errexit(); return 0; } // report a fatal error and stop, or record it in check mode. int fatal(char* msg) { errat(); rt.put_s(msg); if (cmode) { dg_close(); chkabort = 1; return 0; } - rt.put_c(10); rt.halt(); + rt.put_c(10); errexit(); return 0; } // report a syntax error at the current token, once per recovery. |
