aboutsummaryrefslogtreecommitdiff
path: root/src/prc1/td.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2026-11-03 10:11:40 +0100
committerXavier Del Campo Romero <xavi92@disroot.org>2026-11-03 10:11:40 +0100
commit766006c5e8e6a4a51f2cc7c173a2054bc219b9f4 (patch)
tree35c3991ca37ef3eed6666c63c2683ac5507b2a07 /src/prc1/td.c
parent3ee275dbb8bcf5df7f54e7659b4a9a8f4f49911d (diff)
downloadprc-766006c5e8e6a4a51f2cc7c173a2054bc219b9f4.tar.gz
Fully support opaque types and forward declsHEADmaster
Diffstat (limited to 'src/prc1/td.c')
-rw-r--r--src/prc1/td.c15
1 files changed, 5 insertions, 10 deletions
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;