diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-02-26 18:39:29 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-02-26 18:39:29 -0500 |
commit | 03b405750adff0e156f344fd4ab02dd5c6bc4da0 (patch) | |
tree | f798a1c6fc191a427369cf4f8dd2ed4076c257de | |
parent | e9aab51e78493adb3ccd99ff671d6bac5d16d10c (diff) |
moved errors from cgen to types.c
-rw-r--r-- | cgen.c | 8 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | test.toc | 6 | ||||
-rw-r--r-- | types.c | 4 |
4 files changed, 10 insertions, 9 deletions
@@ -394,15 +394,13 @@ static Status cgen_type_pre(CGenerator *g, Type *t, Location where) { cgen_write(g, "_slice"); break; case TYPE_VOID: cgen_write(g, "void"); break; - case TYPE_UNKNOWN: - err_print(where, "Can't determine type."); - return false; case TYPE_STRUCT: cgen_write(g, "struct "); cgen_struct_name(g, t->struc); break; case TYPE_TUPLE: case TYPE_EXPR: + case TYPE_UNKNOWN: /* We should never try to generate this type */ assert(0); return false; @@ -1851,10 +1849,8 @@ static Status cgen_val_ptr(CGenerator *g, void *v, Type *t, Location where) { case TYPE_TUPLE: case TYPE_VOID: case TYPE_EXPR: - assert(0); - return false; case TYPE_UNKNOWN: - err_print(where, "Cannot determine type."); + assert(0); return false; case TYPE_ARR: cgen_write(g, "{"); @@ -165,7 +165,6 @@ int main(int argc, char **argv) { fclose(out); err_text_important(&err_ctx, "Errors occured while generating C code.\n"); allocr_free_all(&main_allocr); - fclose(out); return EXIT_FAILURE; } @@ -1,5 +1,7 @@ +realloc ::= fn() int { + #C("4") +}; main ::= fn() { - x :: &int = new(int); - y := x; + y := realloc(); };
\ No newline at end of file @@ -2783,6 +2783,10 @@ static Status types_decl(Typer *tr, Declaration *d) { success = false; goto ret; } + } else if (d->type.kind == TYPE_UNKNOWN) { + err_print(d->where, "Can't determine type of declaration."); + success = false; + goto ret; } if (d->flags & DECL_IS_CONST) { if (d->type.kind == TYPE_PTR) { |