aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--common.h1
-rw-r--r--io.c3
-rw-r--r--main.c3
3 files changed, 6 insertions, 1 deletions
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);
}