[hackers] [scc] Add support for compound literal in expr.c || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Wed, 20 Jan 2016 16:02:23 +0100 (CET)

commit d5999e4023f08294856780febf26edcb4f1cb37f
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Jan 20 12:41:50 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Jan 20 12:41:50 2016 +0100

    Add support for compound literal in expr.c
    
    The support is not yet complete because initilist() is wrong.
    We do not support designator lists, and we fail to decide
    when an initializator is missing the braces. At this point
    it works for C90 initializers, but it fails when there is
    some compound literal.

diff --git a/cc1/cc1.h b/cc1/cc1.h
index f3279a4..430b4e7 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -386,6 +386,7 @@ extern bool cmpnode(Node *np, TUINT val);
 
 /* init.c */
 extern void initializer(Symbol *sym, Type *tp);
+extern Node *initlist(Type *tp);
 
 /* cpp.c */
 extern void icpp(void);
diff --git a/cc1/expr.c b/cc1/expr.c
index 1db5746..1342015 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -820,13 +820,15 @@ cast(void)
         case TQUALIFIER:
         case TYPE:
                 tp = typename();
+ expect(')');
+
+ if (yytoken == '{')
+ return initlist(tp);
+
                 switch (tp->op) {
                 case ARY:
                         error("cast specify an array type");
- case FTN:
- error("cast specify a function type");
                 default:
- expect(')');
                         lp = cast();
                         if ((rp = convert(lp, tp, 1)) == NULL)
                                 error("bad type convertion requested");
diff --git a/cc1/init.c b/cc1/init.c
index 4ed9640..f2b7509 100644
--- a/cc1/init.c
+++ b/cc1/init.c
_AT_@ -87,8 +87,6 @@ designation(Init *ip)
         return ip;
 }
 
-static Node *initlist(Type *tp);
-
 static Node *
 initialize(Type *tp)
 {
_AT_@ -188,7 +186,7 @@ newdesig(Init *ip, Node *np)
         }
 }
 
-static Node *
+Node *
 initlist(Type *tp)
 {
         Init in;
Received on Wed Jan 20 2016 - 16:02:23 CET

This archive was generated by hypermail 2.3.0 : Wed Jan 20 2016 - 16:12:22 CET