wcc: delete unused warning counters and ww err twin
This commit is contained in:
@@ -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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
Pos noPos = { "<none>", 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++;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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])))
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user