From 2ab99da4111ab827b784b1f627c07a4931f7febd Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Tue, 16 Apr 2024 01:26:14 -0700 Subject: decl: Combine typeof and typeof_unqual switch case --- decl.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/decl.c b/decl.c index a9ee504..6e7d360 100644 --- a/decl.c +++ b/decl.c @@ -322,6 +322,7 @@ declspecs(struct scope *s, enum storageclass *sc, enum funcspec *fs, int *align) struct expr *e; enum typespec ts = SPECNONE; enum typequal tq = QUALNONE; + enum tokenkind op; int ntypes = 0; unsigned long long i; @@ -335,7 +336,8 @@ declspecs(struct scope *s, enum storageclass *sc, enum funcspec *fs, int *align) for (;;) { if (typequal(&tq) || storageclass(sc) || funcspec(fs)) continue; - switch (tok.kind) { + op = tok.kind; + switch (op) { /* 6.7.2 Type specifiers */ case TVOID: t = &typevoid; @@ -417,6 +419,7 @@ declspecs(struct scope *s, enum storageclass *sc, enum funcspec *fs, int *align) next(); break; case TTYPEOF: + case TTYPEOF_UNQUAL: next(); expect(TLPAREN, "after 'typeof'"); t = typename(s, &tq); @@ -425,26 +428,13 @@ declspecs(struct scope *s, enum storageclass *sc, enum funcspec *fs, int *align) if (e->decayed) e = e->base; t = e->type; - tq |= e->qual; + if (op == TTYPEOF) + tq |= e->qual; delexpr(e); } ++ntypes; expect(TRPAREN, "to close 'typeof'"); break; - case TTYPEOF_UNQUAL: - next(); - expect(TLPAREN, "after 'typeof_unqual'"); - t = typename(s, NULL); - if (!t) { - e = expr(s); - if (e->decayed) - e = e->base; - t = e->type; - delexpr(e); - } - ++ntypes; - expect(TRPAREN, "to close 'typeof_unqual'"); - break; /* 6.7.5 Alignment specifier */ case TALIGNAS: -- cgit v1.2.3