From 766006c5e8e6a4a51f2cc7c173a2054bc219b9f4 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Tue, 3 Nov 2026 10:11:40 +0100 Subject: Fully support opaque types and forward decls --- src/prc1/td.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/prc1/td.c') diff --git a/src/prc1/td.c b/src/prc1/td.c index b38a9d3..b3c6692 100644 --- a/src/prc1/td.c +++ b/src/prc1/td.c @@ -114,7 +114,7 @@ static int cid(const struct lex *l, struct prv *p) struct type *nt; const struct loc *loc; - if (t) + if (t && t->type != OP) { loc = &t->tk->loc; errloc(id, "type \"%s\" already defined at %s:%d:%d", id->s, loc->f, @@ -263,7 +263,7 @@ static int c(const struct lex *l, struct prv *p) const struct tdconstant *tdc = p->tdc; const struct loc *loc; - if (t) + if (t && t->type != OP) { loc = &t->tk->loc; errloc(id, "type \"%s\" already defined at %s:%d:%d", id->s, loc->f, @@ -372,13 +372,7 @@ static int op(const struct lex *l, struct prv *p) const struct type *t = type_find(fn, tr, id->s); if (t) - { - const struct loc *loc = &t->tk->loc; - - errloc(id, "type \"%s\" already defined at %s:%d:%d", id->s, loc->f, - loc->line, loc->col); - return -1; - } + goto end; else if (!(nt = malloc(sizeof *nt))) { perror("realloc(3)"); @@ -393,6 +387,7 @@ static int op(const struct lex *l, struct prv *p) insert(td, nt); dbg("\tadd opaque type %s (%d:%d)\n", id->s, loc->line, loc->col); +end: reset(p); return 0; } @@ -480,7 +475,7 @@ static int s(const struct lex *l, struct prv *p) struct type *nt; const struct type *t = type_find(fn, tr, id->s); - if (t) + if (t && t->type != OP) { const struct loc *loc = &t->tk->loc; -- cgit v1.2.3