aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2020-03-09 00:08:57 -0700
committerMichael Forney <mforney@mforney.org>2020-03-16 02:21:13 -0700
commit494420db4966e36d8550a86f4252ab4a888369c1 (patch)
tree147c1c7fb7de069cc3230b2e318e1e82a8b03445
parent83965726d5757ad4a68c8e2e756e6a31d59a614d (diff)
downloadcproc-494420db4966e36d8550a86f4252ab4a888369c1.tar.xz
decl: Simplify struct tag parsing slightly
-rw-r--r--decl.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/decl.c b/decl.c
index cff7564..5a8712b 100644
--- a/decl.c
+++ b/decl.c
@@ -162,17 +162,14 @@ tagspec(struct scope *s)
default: fatal("internal error: unknown tag kind");
}
next();
- if (tok.kind == TIDENT) {
- tag = tok.lit;
- next();
+ if (tok.kind == TLBRACE) {
+ tag = NULL;
+ t = NULL;
+ } else {
+ tag = expect(TIDENT, "or '{' after struct/union");
t = scopegettag(s, tag, false);
if (s->parent && !t && tok.kind != TLBRACE && (kind == TYPEENUM || tok.kind != TSEMICOLON))
t = scopegettag(s->parent, tag, true);
- } else if (tok.kind != TLBRACE) {
- error(&tok.loc, "expected identifier or '{' after struct/union");
- } else {
- tag = NULL;
- t = NULL;
}
if (t) {
if (t->kind != kind)