aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/base.zc8
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.