cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 494420db4966e36d8550a86f4252ab4a888369c1
parent 83965726d5757ad4a68c8e2e756e6a31d59a614d
Author: Michael Forney <mforney@mforney.org>
Date:   Mon,  9 Mar 2020 00:08:57 -0700

decl: Simplify struct tag parsing slightly

Diffstat:
Mdecl.c | 13+++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git 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)