# HG changeset patch # User kono # Date 1397046086 -32400 # Node ID 553cd297b0a811689ba110da245bb9a7f502dacc # Parent 785b2bd389823d321d8be4361874dca01345e07f empty struct initialization in decl (finally) in non parse mode diff -r 785b2bd38982 -r 553cd297b0a8 mc-codegen.c --- 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)); } diff -r 785b2bd38982 -r 553cd297b0a8 mc-codegen.h --- 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); diff -r 785b2bd38982 -r 553cd297b0a8 mc-parse.c --- 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,