# HG changeset patch # User Shinji KONO # Date 1396342923 -32400 # Node ID 509a394c5ff935dd878fff0a8c7bc65d0b907922 # Parent 11abda130b916632fcbbb4e684779b581083f5b4 temp4 passed. diff -r 11abda130b91 -r 509a394c5ff9 mc-parse.c --- a/mc-parse.c Tue Apr 01 16:57:16 2014 +0900 +++ b/mc-parse.c Tue Apr 01 18:02:03 2014 +0900 @@ -1558,27 +1558,6 @@ #define LOCAL_STRUCT_INIT_STATIC 1 static int -decl_data_1(int type0,int v,int offset) -{ - // casted initializer (sturct hoge){.a=3,.b=c,...} - - getsym(0); - if (sym==LPAR) { - offset = decl_data_1(type,v,offset); - checksym(RPAR); - } else if (typeid(sym)) { - int t = typename(); - checksym(RPAR); - offset = decl_data(t,v,offset,1); - if (inmode) - offset = list4(CAST,offset,t,type); - } else { - return 0; - } - return offset; -} - -static int decl_data_field(int type1,int v,int offset) { int t1,t2,period=0; @@ -1596,33 +1575,34 @@ if (sym==LC) { mode = STAT; getsym(0); - } 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; - if (inmode) { - int offset1=decl_data_1(car(t1),v,0); - offset1 = reverse0(offset1); - offset=list3(DECL_DATA,offset1,car(t1)); - } else { - offset=decl_data_1(car(t1),v,offset); - 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; + } else if (sym != PERIOD ) { + // have to be a value, no comma cascading values + int mode_save = mode; + int stype = type; + mode=STAT; + int e=expr1(); + mode = mode_save; + int t2 = type; + type = stype; + if (size(t2)==size(type0)) { + // direct assingn case , including (struct hoge){ ... } + if (inmode) { + offset = list3(DECL_DATA,e,type0); + return offset; + } + offset = assign_data(e,type0,v,offset); + return offset; + } + // missing brace case + error(SIERR); + if (inmode) { + offset = list3(DECL_DATA,e,car(t1)); + return offset; + } + offset = assign_data(e,car(t1),v,offset); + t1 = cadr(t1); + if (! ( t1 && sym==COMMA)) return offset; + conv->comma_(); getsym(0); // fall thru } mode=SFDINIT; while(1) { @@ -1891,6 +1871,7 @@ // decl_data_field(t,n,offset) is called inside; } else #endif + // we cannot handle direct struct assign ( struct hoge a = f(); ) here, because of missing brace case if (inmode) { int offset1=decl_data_field(t,v,0); offset1 = reverse0(offset1);