[hackers] [scc] Allow declaration of arrays without size || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 19 Jan 2016 10:55:46 +0100 (CET)

commit 3eb074604d8c04734b97de4ef489f2a94431c5a8
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Jan 19 07:27:19 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Jan 19 07:27:19 2016 +0100

    Allow declaration of arrays without size
    
    Such arrays have incomplete type, but if they are initialized
    them the type is completed with the information taken from the
    initializer.

diff --git a/cc1/decl.c b/cc1/decl.c
index 6453649..33bd1e2 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -728,8 +728,11 @@ identifier(struct decl *dcl)
                 return sym;
 
         /* TODO: Add warning about ANSI limits */
- if (!tp->defined && sclass != EXTERN && sclass != TYPEDEF)
+ if (!tp->defined &&
+ sclass != EXTERN && sclass != TYPEDEF &&
+ !(tp->op == ARY && yytoken == '=')) {
                 errorp("declared variable '%s' of incomplete type", name);
+ }
 
         if (tp->op != FTN) {
                 sym = install(NS_IDEN, sym);
Received on Tue Jan 19 2016 - 10:55:46 CET

This archive was generated by hypermail 2.3.0 : Tue Jan 19 2016 - 11:00:21 CET