ref: 52c03fe958cf55d73b8cd294accdc2c211ff6580
parent: 5772e7b120d9b0221c4dc2b723c44ed7d6fc9801
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Aug 9 11:59:51 EDT 2016
[cc1] Reemit array variables with incomplete type These variables only can happen in the external context, and we are emitting them with an array of size 0, which is not ever emitted, so the solution is to emit it twice and let to the backend to handle the situation.
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -710,6 +710,19 @@
break;
}
sym->flags = flags;
+ if (tp->op == ARY &&
+ !(sym->type->prop&TDEFINED) &&
+ tp->prop&TDEFINED) {
+ /*
+ * The symbol was already emitted, but in case of being an
+ * array it was emitted with an incorrect type, so the most
+ * simple solution is to emit twice the symbol, and let to
+ * the second declaration to have the correct type.
+ */
+ sym->type = tp;
+ sym->flags &= ~SEMITTED;
+ emit(ODECL, sym);
+ }
return sym;