[hackers] [scc] [cc1] Reemit array variables with incomplete type || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 9 Aug 2016 16:04:17 +0200 (CEST)

commit 137e6e88fc39d5fffdd3423e09967f586f39887c
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Aug 9 15:59:51 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Aug 9 16:03:58 2016 +0200

    [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.

diff --git a/cc1/decl.c b/cc1/decl.c
index 8ecb40d..ab13ae1 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -710,6 +710,19 @@ redcl(Symbol *sym, Type *tp, Symbol **pars, int sclass)
                 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;
 
Received on Tue Aug 09 2016 - 16:04:17 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 09 2016 - 16:12:24 CEST