diff options
author | Michael Forney <mforney@mforney.org> | 2020-03-09 00:08:57 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2020-03-16 02:21:13 -0700 |
commit | 494420db4966e36d8550a86f4252ab4a888369c1 (patch) | |
tree | 147c1c7fb7de069cc3230b2e318e1e82a8b03445 | |
parent | 83965726d5757ad4a68c8e2e756e6a31d59a614d (diff) | |
download | cproc-494420db4966e36d8550a86f4252ab4a888369c1.tar.xz |
decl: Simplify struct tag parsing slightly
-rw-r--r-- | decl.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -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) |