diff options
-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) { |