From b6291927ffb898e37fd482b08669b3577e4d669a Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Sat, 30 May 2020 21:01:59 -0700 Subject: encountered bug due to lack of formalized incomplete types. on the next todo --- sys/cmd/cc/ast.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sys') diff --git a/sys/cmd/cc/ast.c b/sys/cmd/cc/ast.c index 14eddb9..4330bcc 100644 --- a/sys/cmd/cc/ast.c +++ b/sys/cmd/cc/ast.c @@ -1670,6 +1670,8 @@ spec(Parser *p, Lexer *lx, uint64 *spec) goto Bad; } + /* NOTE: This offset is needed to correctly obtain Tstruct */ + n++; name = nil; tag = 0; if (t.kind == Aident) { @@ -1677,9 +1679,10 @@ spec(Parser *p, Lexer *lx, uint64 *spec) t = advance(p, lx); } if (t.kind == Albrace) { + /* TODO: we need check if the name exists. */ t = advance(p, lx); /* NOTE: This depends on the enum order. KEEP IN SYNC */ - tag = aggrfunc[i](p, lx, name, 1 << (n+1)); + tag = aggrfunc[i](p, lx, name, Bit(n)); if (t = peek(p, 0), nomatch(t, Arbrace)) { errorat(t.pos, "invalid token %s in aggregate/enum declaration", tokens[t.kind]); goto Bad; @@ -1687,11 +1690,10 @@ spec(Parser *p, Lexer *lx, uint64 *spec) /* high bits encode the type index */ s |= (uint64)tag << 32; } + /* TODO: if name does not exist, enter in an incomplete type! */ if (name) declaretag(p, tag, name); - /* NOTE: This offset is needed to correctly obtain Tstruct */ - n++; break; default: -- cgit v1.2.1