summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgen.c8
-rw-r--r--main.c1
-rw-r--r--test.toc6
-rw-r--r--types.c4
4 files changed, 10 insertions, 9 deletions
diff --git a/cgen.c b/cgen.c
index 69a4dba..d37526d 100644
--- a/cgen.c
+++ b/cgen.c
@@ -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, "{");
diff --git a/main.c b/main.c
index d63b95b..9cee1c1 100644
--- a/main.c
+++ b/main.c
@@ -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;
}
diff --git a/test.toc b/test.toc
index 01c9646..13929e8 100644
--- a/test.toc
+++ b/test.toc
@@ -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
diff --git a/types.c b/types.c
index 75f8f8a..f8f544b 100644
--- a/types.c
+++ b/types.c
@@ -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) {