aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/parse.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-08 10:22:43 +0200
committerlemon <lsof@mailbox.org>2022-08-08 10:25:08 +0200
commit013e4912833ebe5db705a0e8b3bd1c2ef62ef453 (patch)
treea965a81bb47b559591fcc7e5a5f6a98784b70ec6 /bootstrap/parse.c
parent28eac2940efa05b3a99dd53870ea22b49e12c43a (diff)
expand macros at toplevel
Diffstat (limited to 'bootstrap/parse.c')
-rw-r--r--bootstrap/parse.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c
index fd2d703..ccdb510 100644
--- a/bootstrap/parse.c
+++ b/bootstrap/parse.c
@@ -2962,7 +2962,14 @@ parsedecl(decl_yielder_t yield, void *yarg, struct parser *P, bool toplevel) {
free(cf.decls.d);
lexexpect(P, ';');
return;
+ } else if (lexmatch(P, &tok, TKident)) {
+ const struct decl *dm = finddecl(P, tok.str);
+ if (!dm || dm->t != Dmacro)
+ goto err;
+ parseexpandmacro(P, &dm->macro);
+ return parsedecl(yield, yarg, P, toplevel);
} else {
+ err:
fatal(P, tok.span, "expected declaration (near %s)",
tok2str(tok));
}