checking if a type was already defined
This commit is contained in:
parent
2f5dfe381e
commit
135baed51e
2 changed files with 7 additions and 2 deletions
|
|
@ -3,9 +3,9 @@ struct a {
|
|||
}
|
||||
|
||||
struct b {
|
||||
c ciao,
|
||||
u32 ciao,
|
||||
}
|
||||
|
||||
struct c {
|
||||
b test,
|
||||
u32 test,
|
||||
}
|
||||
|
|
|
|||
5
sema.c
5
sema.c
|
|
@ -85,6 +85,9 @@ static void order_type(sema *s, ast_node *node)
|
|||
graph_node = arena_alloc(s->allocator, sizeof(pair));
|
||||
graph_node->node.in = NULL;
|
||||
graph_node->node.out = NULL;
|
||||
} else if (graph_node->complete) {
|
||||
error(node, "type already defined.");
|
||||
return;
|
||||
}
|
||||
graph_node->node.value = t;
|
||||
|
||||
|
|
@ -101,6 +104,7 @@ static void order_type(sema *s, ast_node *node)
|
|||
p->node.out = NULL;
|
||||
p->node.in = NULL;
|
||||
p->node.value = NULL;
|
||||
p->complete = false;
|
||||
shput(types, name, p);
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +115,7 @@ static void order_type(sema *s, ast_node *node)
|
|||
}
|
||||
|
||||
shput(types, k, graph_node);
|
||||
graph_node->complete = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue