# HG changeset patch # User Shinji KONO # Date 1396727434 -32400 # Node ID 2466ac7c1287fee8475853629bfd221f9218279c # Parent b519139c25e2fe580b029634b2cda287c1ed3198 remove no-controled statement in inline diff -r b519139c25e2 -r 2466ac7c1287 mc-codegen.c --- a/mc-codegen.c Sat Apr 05 23:42:08 2014 +0900 +++ b/mc-codegen.c Sun Apr 06 04:50:34 2014 +0900 @@ -623,26 +623,27 @@ case DECL_DATA: e1 = gen_decl_data(e1,0); return e1; - case ST_DECL: st_decl(e1); break; - case ST_IF: st_if(e1); break; - case ST_DO: st_do(e1); break; - case ST_WHILE: st_while(e1); break; - case ST_FOR: st_for(e1); break; - case ST_SWITCH: st_switch(e1); break; - case ST_COMP: st_comp(e1); break; + case ST_DECL: checkretpening(); st_decl(e1); break; + case ST_IF: checkretpening(); st_if(e1); break; + case ST_DO: checkretpening(); st_do(e1); break; + case ST_WHILE: checkretpening(); st_while(e1); break; + case ST_FOR: checkretpening(); st_for(e1); break; + case ST_SWITCH: checkretpening(); st_switch(e1); break; + case ST_COMP: checkretpening();st_comp(e1); break; case ST_BREAK: st_break(e1); break; case ST_CONTINUE: st_continue(e1); break; case ST_CASE: st_case(e1); break; case ST_DEFAULT: st_default(e1); break; case ST_RETURN: st_return(e1); break; - case ST_GOTO: st_goto(e1); break; - case ST_ASM: st_asm(e1); break; + case ST_GOTO: checkret(); st_goto(e1); break; + case ST_ASM: checkret(); st_asm(e1); break; case ST_LABEL: st_label(e1); break; case ST_COMMENT: st_comment(e1); break; case ST_OP: + checkretpening(); e3=caddr(e1); e1=binop(e2,car(e1),cadr(e3),caddr(e3),cadddr(e3)); - return g_expr0(e1); + continue; case IVAR: error(-1); break; case 0: error(-1); @@ -4318,6 +4319,16 @@ */ extern void +checkretpening(void) +{ + if (retpending) { + ret(); + control=0; + retpending=0; + } +} + +extern void checkret(void) { int lastexp0; diff -r b519139c25e2 -r 2466ac7c1287 mc-codegen.h --- a/mc-codegen.h Sat Apr 05 23:42:08 2014 +0900 +++ b/mc-codegen.h Sun Apr 06 04:50:34 2014 +0900 @@ -74,6 +74,7 @@ extern int strop(int e,int ind); extern void arg_register(NMTBL *fnptr, int in); extern int bexpr(int e1, char cond, int l1); +extern void checkretpening(void); extern void checkret(void); // check delayed jump, delayed last exp extern void closing(); extern void cmpdimm(int e, int csreg,int label,int cond); diff -r b519139c25e2 -r 2466ac7c1287 mc-inline.c --- a/mc-inline.c Sat Apr 05 23:42:08 2014 +0900 +++ b/mc-inline.c Sun Apr 06 04:50:34 2014 +0900 @@ -357,12 +357,19 @@ extern void st_default(int e1){ + // int clist=caddr(e1); // int cst = (car(csvalue1)==CONST); + // if (cst) { + // int c=cadr(csvalue1); + // for(;clist;clist=cadr(clist)) { + // if (car(clist)==c) break; + // } + // if (!clist) return; // no match + // } control=1; checkret(); if (dlabel) error(STERR); // double default: dlabel = backdef(); - // conv->case_(0,1); } diff -r b519139c25e2 -r 2466ac7c1287 test/strinit.c --- a/test/strinit.c Sat Apr 05 23:42:08 2014 +0900 +++ b/test/strinit.c Sun Apr 06 04:50:34 2014 +0900 @@ -218,8 +218,8 @@ -INLINE void f(struct arg h) { - printf("#0221:%d %d %d\n",h.hage,h.fuga,h.aho); +INLINE void f(int i, struct arg h) { + printf("#0221:%d=%d %d %d\n",i,h.hage,h.fuga,h.aho); } INLINE int main8() { @@ -228,15 +228,18 @@ struct arg c; struct arg d = {}; struct arg e = (struct arg){}; - f(a); - f(b); - f(c); - f(d); - f(e); - f((struct arg){.fuga = 3,.aho=5}); - f((struct arg){.hage = 3}); - f((struct arg){}); - printf("#0226:%d %d\n",a.aho,((struct arg){.aho=120, .hage=55}).aho); return 0; + f(0,a); + f(1,b); + f(2,c); + f(3,d); + f(4,e); + f(5,(struct arg){.fuga = 3,.aho=5}); + f(6,(struct arg){.hage = 3}); + f(7,(struct arg){}); + printf("#0226:%d %d\n",a.aho,((struct arg){.aho=120, .hage=55}).aho); + printf("#0227:%d %d\n",a.aho,((struct arg){.aho=120, .hage=55}).fuga); + return 0; + printf("#0229:%d %d\n",a.aho,((struct arg){.aho=120, .hage=55}).fuga); // unexecuted code } int diff -r b519139c25e2 -r 2466ac7c1287 test/switch.c --- a/test/switch.c Sat Apr 05 23:42:08 2014 +0900 +++ b/test/switch.c Sun Apr 06 04:50:34 2014 +0900 @@ -1247,7 +1247,9 @@ main1(15); main2(16); main3(17); + main3(60); main4(19); + main4(-109); main5(19); for(i=-1000;i<3000;i++) { // main1(i);