aboutsummaryrefslogtreecommitdiffhomepage
path: root/c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-02-24 14:09:19 +0100
committerlemon <lsof@mailbox.org>2026-02-24 14:09:19 +0100
commitf73f0301fd2d4306f173984fc8089ad463da26fe (patch)
tree8e20f34b0d2a7b621ec3dd8b44e563ed359e3f77 /c
parent6417c31a69ce06f35e00771fd2ecc87dbe48cd7a (diff)
diagnostics: also print #include provenance for warnings
Diffstat (limited to 'c')
-rw-r--r--c/lex.c3
-rw-r--r--c/lex.h4
2 files changed, 4 insertions, 3 deletions
diff --git a/c/lex.c b/c/lex.c
index 329862e..a2f1596 100644
--- a/c/lex.c
+++ b/c/lex.c
@@ -1668,6 +1668,7 @@ tryinclude(struct lexer *lx, const struct span *span, char *path)
case LXOK:
new.save = xmalloc(sizeof *new.save);
lx->inclnerror = nerror;
+ lx->inclnwarn = nwarn;
memcpy(new.save, lx, sizeof *lx);
*lx = new;
@@ -2036,7 +2037,7 @@ Begin:
markfileonce(lx->fileid, lx->inclguard);
}
struct lexer *sv = lx->save;
- if (sv->inclnerror != nerror) {
+ if (sv->inclnerror != nerror || sv->inclnwarn != nwarn) {
int line;
const char *f = getfilepos(&line, NULL, sv->fileid, sv->chridx-2);
note(NULL, "in file included from %s:%d", f, line);
diff --git a/c/lex.h b/c/lex.h
index c4c38e8..35cf77d 100644
--- a/c/lex.h
+++ b/c/lex.h
@@ -88,7 +88,7 @@ struct token {
*/
};
-extern int nerror;
+extern int nerror, nwarn;
struct lexer {
struct lexer *save;
short fileid;
@@ -102,7 +102,7 @@ struct lexer {
struct arena **tmparena;
bool firstdirective;
short nppcnd0;
- short inclnerror;
+ short inclnerror, inclnwarn;
internstr inclguard;
uchar chrbuf[1<<10];
uint chridxbuf[1<<10];