aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/parse.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-07 16:02:34 +0200
committerlemon <lsof@mailbox.org>2022-08-07 16:02:34 +0200
commit81500312dcfdde2bd07c5071c7948a61b1f952ba (patch)
tree377ffd4c263a5f4984376793692eb5f71eda8983 /bootstrap/parse.c
parent92bbf45f333bbf9190befc52a6bc114dc2957e41 (diff)
expand template at expression position
Diffstat (limited to 'bootstrap/parse.c')
-rw-r--r--bootstrap/parse.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c
index 4094edb..e7f4a39 100644
--- a/bootstrap/parse.c
+++ b/bootstrap/parse.c
@@ -583,6 +583,7 @@ parseexpandtepl(struct parser *P, struct tepl *tepl) {
const struct type *ty = NULL;
int i = 0;
+ lexexpect(P, '<');
expan.span = container_of(tepl, struct decl, tepl)->span;
expan.tepl = 1;
while (!lexmatch(P, &tok, '>')) {
@@ -726,7 +727,6 @@ parsetype(struct parser *P) {
if (decl->t == Dtype) {
return decl->ty;
} else if (decl->t == Dtepl && decl->tepl.t == Dtype) {
- lexexpect(P, '<');
return parseexpandtepl(P, (struct tepl *)&decl->tepl);
} else
fatal(P, P->tokspan, "%T is not a type", tok);
@@ -974,8 +974,10 @@ pexprimary(struct parser *P) {
decl:
if (!decl)
fatal(P, tok.span, "%T is not defined", tok);
+ const struct type *ty;
if (decl->t == Dtype) {
- const struct type *ty = decl->ty;
+ ty = decl->ty;
+ typedecl:
if (ty->t == TYenum) {
lexexpect(P, ':');
P->targty = ty;
@@ -1001,6 +1003,9 @@ pexprimary(struct parser *P) {
} else if (decl->t == Dmacro) {
parseexpandmacro(P, &decl->macro);
ex = parseexpr(P);
+ } else if (decl->t == Dtepl) {
+ ty = parseexpandtepl(P, (struct tepl *)&decl->tepl);
+ goto typedecl;
} else {
ex.t = Ename;
ex.span = tok.span;