aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/parse.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-13 10:38:27 +0200
committerlemon <lsof@mailbox.org>2022-08-13 10:38:27 +0200
commit7d4cb5bb96b061ed8708889b75e4d50757d9b3f2 (patch)
treeb57fdfa2dd7d61b888930d45c5f8f6f873db39ff /bootstrap/parse.c
parent62132ecc8d032ef251d6b54177414a9ba29e8610 (diff)
set template
Diffstat (limited to 'bootstrap/parse.c')
-rw-r--r--bootstrap/parse.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c
index 74ab2e2..874b54d 100644
--- a/bootstrap/parse.c
+++ b/bootstrap/parse.c
@@ -800,6 +800,9 @@ parsetype(struct parser *P) {
struct decl *_decl;
return parseagg(P, NULL, TYunion, &_decl);
} else if (lexmatch(P, &tok, TKkw_enum)) {
+ struct decl *_decl;
+ if (lexmatch(P, NULL, TKkw_union))
+ return parseagg(P, NULL, TYeunion, &_decl);
return parseenum(P, NULL, (struct attr){0});
} else if (lexmatch(P, &tok, TKkw_typeof)) {
const struct type *ty = NULL, *ty2, *ty0;
@@ -1027,6 +1030,7 @@ static struct expr
pexprimary(struct parser *P) {
struct expr ex = {0};
struct tok tok;
+ const struct type *ty;
P->used_targty = 0;
@@ -1071,7 +1075,6 @@ pexprimary(struct parser *P) {
decl:
if (!decl)
fatal(P, tok.span, "%T is not defined", tok);
- const struct type *ty;
if (decl->t == Dtype) {
ty = decl->ty;
typedecl:
@@ -1123,6 +1126,9 @@ pexprimary(struct parser *P) {
ex.ty = decl->fn.selfty;
} else assert(0);
}
+ } else if (lexmatch(P, &tok, TKtype)) {
+ ty = tok.ty;
+ goto typedecl;
} else if (lexmatch(P, &tok, '(')) {
if (lexpeek(P).t == TKkw_do) {
struct blockstmt block;
@@ -2789,7 +2795,7 @@ parseagg(struct parser *P, const char *name, int kind, struct decl **retdecl) {
const char *fnam = (tok = lexexpect(P, TKident)).str;
const struct type *ty = NULL;
size_t off = size;
- if (kind != TYeunion || ((tok = lexpeek(P)).t != ',' && tok.t != '}' && !isdecltokt(tok.t))) {
+ if (kind != TYeunion || ((tok = lexpeek(P)).t != ',' && tok.t != '}' && tok.t != TKkw_fn)) {
ty = parsetype(P);
if (f0align < 0)
f0align = ty->align;
@@ -2857,6 +2863,7 @@ parseagg(struct parser *P, const char *name, int kind, struct decl **retdecl) {
size_t off = f0align < 0 ? 0 : ALIGNUP(enumty.size, f0align);
ppty->size += off;
align = MAX(align, enumty.align);
+ ppty->size = ALIGNUP(ppty->size, align);
for (int i = 0; i < ppty->agg.flds.n; ++i)
ppty->agg.flds.d[i].off += off;