From e7671ddf611be4ab62deb1b6e2d0d3862c75dec6 Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 11 Dec 2025 12:28:40 +0100 Subject: driver: add -Werror --- common.h | 1 + io.c | 3 ++- main.c | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/common.h b/common.h index d363038..ce7d604 100644 --- a/common.h +++ b/common.h @@ -129,6 +129,7 @@ struct option { bool trigraph; bool nocolor; bool pie, pic; + bool werror; union { struct { bool p : 1, /* after parsing */ diff --git a/io.c b/io.c index ab3499b..b2d4364 100644 --- a/io.c +++ b/io.c @@ -1072,8 +1072,9 @@ warn(const struct span *span, const char *fmt, ...) { va_list ap; + if (ccopt.werror) ++nerror; va_start(ap, fmt); - vdiag(span, DGWARN, fmt, ap); + vdiag(span, ccopt.werror ? DGERROR : DGWARN, fmt, ap); va_end(ap); } diff --git a/main.c b/main.c index c0016ed..3833d85 100644 --- a/main.c +++ b/main.c @@ -202,6 +202,9 @@ optparse(char **args) } /* TODO depfiles */ } else if (*arg == 'W') { + if (!strcmp(arg+1, "error")) { + ccopt.werror = 1; + } /* TODO warning switches */ } else Bad: warn(NULL, "unrecognized option: %'s", arg-1); } -- cgit v1.2.3