changeset 890:9d5da127f462

inline partial struct init in declaration.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 06 Apr 2014 12:49:08 +0900
parents 6a92d3e8a4b5
children ece860823251
files mc-codegen.c mc-inline.c
diffstat 2 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mc-codegen.c	Sun Apr 06 11:54:08 2014 +0900
+++ b/mc-codegen.c	Sun Apr 06 12:49:08 2014 +0900
@@ -3887,7 +3887,12 @@
                 error(-1);
         }
         e = caddr(init);
-        if (!e) continue;  // {...,} case
+        if (!e) {  // {...,} case
+            int sz = size(target_type);
+            zfill(v, offset, sz);
+            offset += sz;
+            continue;
+        }
         offset = gen_decl_data0(v,car(type0),e,offset);
         type0 = cadr(type0);
     }
--- a/mc-inline.c	Sun Apr 06 11:54:08 2014 +0900
+++ b/mc-inline.c	Sun Apr 06 12:49:08 2014 +0900
@@ -1499,9 +1499,7 @@
 #endif
     case CAST:
         if (e2==0) {
-            // casted empty structure  (struct hoge){}
-            // I think we can skip it. It means nothing in declaration
-            //        but it make zero fill, we have to handle it later
+            error(-1); 
             return 0;
         } else if (car(e2)==DECL_DATA) {
             // casted initialized structure  (struct hoge){...}