aboutsummaryrefslogtreecommitdiff
path: root/src/checker/checker.c
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-12-04 23:25:52 +0000
committerGinger Bill <bill@gingerbill.org>2016-12-04 23:25:52 +0000
commitc71b547cdeecaa4cc7743be18fcc44f6a9da9c39 (patch)
tree458bd31ba6d7b875e9fb1517530d590a425c3ffd /src/checker/checker.c
parent76e724718c7711cc5bcc942178d5955991759589 (diff)
(Crude) Cyclic Type Checking
Diffstat (limited to 'src/checker/checker.c')
-rw-r--r--src/checker/checker.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/checker/checker.c b/src/checker/checker.c
index 60dea3be0..cf95c146b 100644
--- a/src/checker/checker.c
+++ b/src/checker/checker.c
@@ -269,33 +269,9 @@ typedef struct Checker {
bool done_preload;
} Checker;
-typedef struct CycleChecker {
- Array(Entity *) path; // Entity_TypeName
-} CycleChecker;
-
-CycleChecker *cycle_checker_add(CycleChecker *cc, Entity *e) {
- if (cc == NULL) {
- return NULL;
- }
- if (cc->path.e == NULL) {
- array_init(&cc->path, heap_allocator());
- }
- if (e != NULL && e->kind == Entity_TypeName) {
- array_add(&cc->path, e);
- }
- return cc;
-}
-
-void cycle_checker_destroy(CycleChecker *cc) {
- if (cc != NULL && cc->path.e != NULL) {
- array_free(&cc->path);
- }
-}
-
-
void init_declaration_info(DeclInfo *d, Scope *scope) {
d->scope = scope;
map_bool_init(&d->deps, heap_allocator());
@@ -1095,7 +1071,7 @@ void check_all_global_entities(Checker *c) {
Scope *prev_scope = c->context.scope;
c->context.scope = d->scope;
- check_entity_decl(c, e, d, NULL, NULL);
+ check_entity_decl(c, e, d, NULL);
if (d->scope->is_init && !c->done_preload) {
@@ -1488,6 +1464,14 @@ void check_parsed_files(Checker *c) {
add_type_info_type(c, t);
}
}
+
+ for_array(i, c->info.definitions.entries) {
+ Entity *e = c->info.definitions.entries.e[i].value;
+ if (e->kind == Entity_TypeName) {
+ i64 align = type_align_of(c->sizes, c->allocator, e->type);
+ GB_ASSERT(align > 0);
+ }
+ }
}