diff options
author | Michael Forney <mforney@mforney.org> | 2024-04-16 01:26:14 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2024-04-16 01:26:14 -0700 |
commit | 2ab99da4111ab827b784b1f627c07a4931f7febd (patch) | |
tree | 5a0aa9c410670c415bbc6a32229a5df04608edc3 | |
parent | 5762c6fc23b458fa16ee0ea4f5d50430d6059e2a (diff) |
decl: Combine typeof and typeof_unqual switch case
-rw-r--r-- | decl.c | 22 |
1 files changed, 6 insertions, 16 deletions
@@ -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: |