ref: ee4660c4b1081fbe4d5ae68a68132f9e1b629a5c
parent: 245fc40cffc3b201f5cdf9e1b485fc7fa06e1463
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Jan 19 05:49:29 EST 2016
Do not emit decalrations until initializer Incomplete array types are converted to complete when they have a initializer, but incomplete types are not emited, so it is impossible for the backend to know what is the size of the initializer.
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -789,12 +789,12 @@
sym->flags = flags;
}
- if (sym->token == IDEN && sym->type->op != FTN)
- emit(ODECL, sym);
if (accept('='))
initializer(sym, sym->type);
if (!(sym->flags & (ISGLOBAL|ISEXTERN)) && tp->op != FTN)
sym->flags |= ISDEFINED;
+ if (sym->token == IDEN && sym->type->op != FTN)
+ emit(ODECL, sym);
return sym;
}
--- a/cc1/init.c
+++ b/cc1/init.c
@@ -244,6 +244,7 @@
errorp("function '%s' is initialized like a variable", sym->name);
np = initialize(tp);
+ emit(ODECL, sym);
if (flags & ISDEFINED) {
errorp("redeclaration of '%s'", sym->name);
} else if ((flags & (ISGLOBAL|ISLOCAL|ISPRIVATE)) != 0) {