diff --git a/cmd/wcc/err.c b/cmd/wcc/err.c index 6cba0028..bea0e7e0 100644 --- a/cmd/wcc/err.c +++ b/cmd/wcc/err.c @@ -1,13 +1,11 @@ /* - * Plan 9 style: short, no levels beyond fatal/error/warn, no colour. + * Plan 9 style: short, no levels beyond fatal/error, no colour. */ #include "ww.h" #include #include Pos noPos = { "", 0, 0 }; -int nerrors; -int nwarnings; FILE *errout; /* set by main; defaults to stderr */ static FILE * @@ -52,19 +50,4 @@ errorf(Pos p, const char *fmt, ...) vfprintf(f, fmt, ap); va_end(ap); fprintf(f, "\n"); - nerrors++; -} - -void -warnf(Pos p, const char *fmt, ...) -{ - FILE *f = out(); - va_list ap; - prefix(p); - fprintf(f, "warning: "); - va_start(ap, fmt); - vfprintf(f, fmt, ap); - va_end(ap); - fprintf(f, "\n"); - nwarnings++; } diff --git a/cmd/wcc/parse.c b/cmd/wcc/parse.c index 719ded7a..0e31b020 100644 --- a/cmd/wcc/parse.c +++ b/cmd/wcc/parse.c @@ -210,9 +210,8 @@ parsetype(Parser *p) if (p->cur.kind == TK_AT) { advance(p); const char *an = expectident(p); - /* p->errs gates the build (cmd/w6c/main.c:82); - * nerrors is advisory-only, so an errorf on a - * clean-recovery path must bump p->errs itself. */ + /* errorf only reports; p->errs gates the build + * (cmd/w6c/main.c:82). */ if (strcmp(an, "packed") != 0) { errorf(p->cur.pos, "unknown struct attribute '@%s'", an); diff --git a/cmd/wcc/ww.h b/cmd/wcc/ww.h index 28797fc9..df20ffd0 100644 --- a/cmd/wcc/ww.h +++ b/cmd/wcc/ww.h @@ -58,13 +58,10 @@ struct Pos { }; extern Pos noPos; -extern int nerrors; -extern int nwarnings; extern FILE *errout; void fatal(const char*, ...) __attribute__((noreturn, format(printf, 1, 2))); void errorf(Pos, const char*, ...) __attribute__((format(printf, 2, 3))); -void warnf(Pos, const char*, ...) __attribute__((format(printf, 2, 3))); #define nelem(a) ((sizeof(a) / sizeof((a)[0]))) diff --git a/selfhost/cmd/wcc/check.ww b/selfhost/cmd/wcc/check.ww index 263ce52a..95be8b23 100644 --- a/selfhost/cmd/wcc/check.ww +++ b/selfhost/cmd/wcc/check.ww @@ -40,8 +40,7 @@ type checker = struct { // diagnostics. Tool-local (NOT a lib wrapper): messages are built from // many fragments and we route through os.write to avoid libc stdio. // .len replaces the error-prone hand-counted byte literals these sites -// carried. Lives here (not err.ww) because the selfhost build pulls -// check.ww but not err.ww (which ports err.c for the C-driven path). +// carried. fn cerr(m: str) void = { os.write(2, m.ptr, m.len: u64); }; diff --git a/selfhost/cmd/wcc/err.ww b/selfhost/cmd/wcc/err.ww deleted file mode 100644 index 43933a0c..00000000 --- a/selfhost/cmd/wcc/err.ww +++ /dev/null @@ -1,38 +0,0 @@ -// Port of cmd/wcc/err.c. Plan 9 style: short, no levels beyond -// fatal/error/warn. Output goes through os.write so we don't pull in -// libc stdio. - -package wcc; - -import os; -import fmt; - -type pos = struct { - file: str, - line: i32, - col: i32, -}; - -let nerrors: i32 = 0; -let nwarnings: i32 = 0; - -export fn fatal(msg: str) void = { - fmt.errorln(msg); - os.exit(1); -}; - -export fn errorf(p: pos, msg: str) void = { - os.write(2, p.file.ptr, p.file.len: u64); - os.write(2, ": error: ".ptr, 9u64); - os.write(2, msg.ptr, msg.len: u64); - os.write(2, "\n".ptr, 1u64); - nerrors += 1; -}; - -export fn warnf(p: pos, msg: str) void = { - os.write(2, p.file.ptr, p.file.len: u64); - os.write(2, ": warning: ".ptr, 11u64); - os.write(2, msg.ptr, msg.len: u64); - os.write(2, "\n".ptr, 1u64); - nwarnings += 1; -};