aboutsummaryrefslogtreecommitdiffhomepage
path: root/c/lex.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-20 22:00:28 +0100
committerlemon <lsof@mailbox.org>2025-12-20 22:00:28 +0100
commit497289eb02927c75f6e77bba052bec2a4589c227 (patch)
treee308c60f6d5ce8569eeb3159b45a5bebc1d8dda5 /c/lex.c
parent8341b8fa4ede60ff92127825a0b2e6b29f5e4d83 (diff)
lexer: note source of #include when error occurs in #included file
Diffstat (limited to 'c/lex.c')
-rw-r--r--c/lex.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/c/lex.c b/c/lex.c
index 5c627f1..6fa6fa3 100644
--- a/c/lex.c
+++ b/c/lex.c
@@ -1507,6 +1507,7 @@ tryinclude(struct lexer *lx, const struct span *span, char *path)
/* fallthru */
case LXOK:
new.save = xmalloc(sizeof *new.save);
+ lx->inclnerror = nerror;
memcpy(new.save, lx, sizeof *lx);
*lx = new;
@@ -1850,6 +1851,11 @@ Begin:
markfileonce(lx->fileid, lx->inclguard);
}
struct lexer *sv = lx->save;
+ if (sv->inclnerror != nerror) {
+ int line;
+ const char *f = getfilepos(&line, NULL, sv->fileid, sv->chridx-2);
+ note(NULL, "in file included from %s:%d", f, line);
+ }
memcpy(lx, sv, sizeof *lx);
free(sv);
--includedepth;