changeset 912:553cd297b0a8

empty struct initialization in decl (finally) in non parse mode
author kono
date Wed, 09 Apr 2014 21:21:26 +0900
parents 785b2bd38982
children 7aa39f5128f9 f7803d618f36
files mc-codegen.c mc-codegen.h mc-parse.c
diffstat 3 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mc-codegen.c	Wed Apr 09 14:39:32 2014 +0900
+++ b/mc-codegen.c	Wed Apr 09 21:21:26 2014 +0900
@@ -4052,9 +4052,12 @@
 }
 
 extern void
-data_closing(int e)
+data_closing(int e,int type)
 {
     if (!chk) {
+	if (!inmode && type>0&&(car(type)==STRUCT||car(type)==UNION) && decl_str_init==0) {
+	    zfill(e,0,size(type));
+	}
         if (decl_str_init) gen_delayed_decl_data(e,0);
         emit_data_closing(ncaddr(e));
     }
--- a/mc-codegen.h	Wed Apr 09 14:39:32 2014 +0900
+++ b/mc-codegen.h	Wed Apr 09 21:21:26 2014 +0900
@@ -81,7 +81,7 @@
 extern void codegen_decl_init(); /* called before each declaration */
 extern void codegen_init();      /* called only once */
 extern void codegen_reinit();    /* called for each file */
-extern void data_closing(int v);
+extern void data_closing(int v,int type);
 extern void df_label(int cslabel, int dlabel);
 extern void emit_init_vars(void);
 extern void fcheck(NMTBL *n);
--- a/mc-parse.c	Wed Apr 09 14:39:32 2014 +0900
+++ b/mc-parse.c	Wed Apr 09 21:21:26 2014 +0900
@@ -968,7 +968,7 @@
         v = list3n(n->sc,n->dsp,n);
         if (sym==ASS && n!=&null_nptr) { 
             conv->op_(sym);
-            init = decl_data_def(n, type,v,0,0); data_closing(v); 
+            init = decl_data_def(n, type,v,0,0); data_closing(v,type); 
         }
         if (inmode && (mode==LDECL||mode==LLDECL||mode==STADECL)) { 
             parse = list5n(ST_DECL,parse,list3(mode,stmode,ctmode),init,n);
@@ -990,7 +990,7 @@
             v = list3n(n->sc,n->dsp,n);
             if (sym==ASS && n!=&null_nptr) {
                 conv->op_(sym);
-                init = decl_data_def(n, type,v,0,0);data_closing(v);
+                init = decl_data_def(n, type,v,0,0);data_closing(v,type);
             }
             if (inmode && mode==LDECL) {
                 parse = list5n(ST_DECL,parse,