# HG changeset patch # User Shinji KONO # Date 1396339036 -32400 # Node ID 11abda130b916632fcbbb4e684779b581083f5b4 # Parent 662e2b778fc25c5c86d8fb5420b16390bc869ae4 struct init on going ... diff -r 662e2b778fc2 -r 11abda130b91 mc-code-ia32.c --- a/mc-code-ia32.c Tue Apr 01 11:28:49 2014 +0900 +++ b/mc-code-ia32.c Tue Apr 01 16:57:16 2014 +0900 @@ -3196,26 +3196,18 @@ void code_builtin_fabsf(int e) { - int e1 = USE_CREG; - use_float(0,e1); } void code_builtin_fabs(int e) { - int e1 = USE_CREG; - use_float(1,e1); } void code_builtin_inff() { - int e1 = USE_CREG; - use_float(0,e1); } void code_builtin_inf() { - int e1 = USE_CREG; - use_float(1,e1); } void code_dneg(int freg,int d) diff -r 662e2b778fc2 -r 11abda130b91 mc-parse.c --- a/mc-parse.c Tue Apr 01 11:28:49 2014 +0900 +++ b/mc-parse.c Tue Apr 01 16:57:16 2014 +0900 @@ -1560,44 +1560,32 @@ static int decl_data_1(int type0,int v,int offset) { - int t = type0; - // casted initializer (sturct hoge){.a=3,.b=c,...} + + getsym(0); if (sym==LPAR) { - getsym(0); offset = decl_data_1(type,v,offset); checksym(RPAR); } else if (typeid(sym)) { - t = typename(); + int t = typename(); checksym(RPAR); offset = decl_data(t,v,offset,1); if (inmode) offset = list4(CAST,offset,t,type); } else { - int mode_save = mode; - mode=STAT; - int e=expr1(); - mode = mode_save; - if (inmode) { - offset = list3(DECL_DATA,e,type); - type=t; - return offset; - } - offset = assign_data(e,t,v,offset); - type=t; - return offset; + return 0; } return offset; } static int -decl_data_field(int type,int v,int offset) +decl_data_field(int type1,int v,int offset) { int t1,t2,period=0; int foffset; // int offset0 = offset+size(type); int mode_save=mode; - int type0=type_value(type); + int type0=type_value(type1); NMTBL *nptr1; if(cadr(type0)==-1) { // no struct field defenition @@ -1608,23 +1596,33 @@ if (sym==LC) { mode = STAT; getsym(0); - } else { + } else if (sym==LPAR) { // have to be a value, no comma cascading values // .__tcp_lhash_lock = (rwlock_t) { }, // We cannot distinguish this case and cascading comma here. // Do it more upper syntactical node; - int par = (sym==LPAR); - if (par) getsym(0); if (inmode) { int offset1=decl_data_1(car(t1),v,0); offset1 = reverse0(offset1); offset=list3(DECL_DATA,offset1,car(t1)); - return offset; } else { offset=decl_data_1(car(t1),v,offset); - if (!offset && par ) checksym(RPAR); + if (!offset) checksym(RPAR); + } + return offset; + } else { + int mode_save = mode; + int stype = type; + mode=STAT; + int e=expr1(); + mode = mode_save; + type = stype; + if (inmode) { + offset = list3(DECL_DATA,e,car(t1)); return offset; } + offset = assign_data(e,car(t1),v,offset); + return offset; } mode=SFDINIT; while(1) { @@ -1633,7 +1631,7 @@ getsym(0); if (sym==IDENT) { nptr1 = nptr; - t2 = search_struct_type(type,nptr1->nm,&foffset); + t2 = search_struct_type(type1,nptr1->nm,&foffset); if (!t2) error(UFLDERR); getsym(0); if (sym==ASS) { @@ -1902,8 +1900,8 @@ } conv->decl_data_end_(); conv->rc_(); if (lc) { - while (sym==COMMA) getsym(0); // why we need this?! - checksym(RC); + while (sym==COMMA) getsym(0); // why we need this?! + checksym(RC); } return offset; } diff -r 662e2b778fc2 -r 11abda130b91 test/ps2.c --- a/test/ps2.c Tue Apr 01 11:28:49 2014 +0900 +++ b/test/ps2.c Tue Apr 01 16:57:16 2014 +0900 @@ -76,8 +76,8 @@ if(!this) return; if(this->mtd) this->mtd( this ); if(this->draw) this->draw( this, work, base ); - printf("#0078:offset draw %ld\n",((char*)(&this->draw) - ((char*)&this->object))); - printf("#0079:offset next %ld\n",((char*)(&this->next) - ((char*)&this->object))); + printf("#0078:offset draw %ld\n",(long)((char*)(&this->draw) - ((char*)&this->object))); + printf("#0079:offset next %ld\n",(long)((char*)(&this->next) - ((char*)&this->object))); if(this->child) graphic_ObjNode_draw( this->child, work ); if(this->next) graphic_ObjNode_draw( this->next, base );