# HG changeset patch # User Shinji KONO # Date 1396699963 -32400 # Node ID 1a027275743d85aeb3e92963995bc6e173533df4 # Parent f915d5ba033e436effbed4e5133ace225c9ef9d3 struct returinng function have to be indirect. diff -r f915d5ba033e -r 1a027275743d mc-parse.c --- a/mc-parse.c Sat Apr 05 19:37:34 2014 +0900 +++ b/mc-parse.c Sat Apr 05 21:12:43 2014 +0900 @@ -4485,7 +4485,7 @@ /* return type */ - + NMTBL *tmp = 0; type = cadr(ftype); type0 = type_value(type); if(type0==CHAR||type0==SHORT) type=set_type_with_attr(INT,type); @@ -4494,23 +4494,25 @@ /* temporal struct is required */ - NMTBL *tmp = make_tmp_struct(); + tmp = make_tmp_struct(); e = list3n(inmode?IVAR:LVAR,tmp->dsp,tmp); /* pass the pointer as an argument */ /* this is recognized by called function declaration */ /* but I don't know this sequence is compatible with gcc */ - arglist = append3(arglist,list2(ADDRESS,e),list2(POINTER,type)); + } if (car(e1)==FNAME) { // recursive inline is not allowed if (ncaddr(e1)!=fnptr && is_inline(ncaddr(e1))) { - return list4(INLINE,e1,arglist,ftype); + if (tmp) return list2(INDIRECT,(list4(INLINE,e1,arglist,ftype))); + else return list4(INLINE,e1,arglist,ftype); } } - return list4(stmode==GOTO?CODE:FUNCTION,e1,arglist,ftype); + if (tmp) return list2(INDIRECT,list4(stmode==GOTO?CODE:FUNCTION,e1,arglist,ftype)); + else return list4(stmode==GOTO?CODE:FUNCTION,e1,arglist,ftype); } static int diff -r f915d5ba033e -r 1a027275743d test/tmp7.c --- a/test/tmp7.c Sat Apr 05 19:37:34 2014 +0900 +++ b/test/tmp7.c Sat Apr 05 21:12:43 2014 +0900 @@ -81,7 +81,7 @@ int j = 3; struct { int b; void (*c)(struct aa); } q = {3,main1},r; struct aa *aap[3]; - + struct bb bb0 = {{1,2}}; // = {1,2}; should be Ok j = 3; aaa.a[0] = 55; @@ -128,9 +128,9 @@ aaa1.b[0]=33; aaa1.b[1]=55; bbb1 = main5(aaa,aaa1); - printf("#0130:main5-2 %d\n", + printf("#0130:main5-2 %d %d\n",bb0.b[0], main5(bbb,bbb1).b[0]); - printf("#0132:main5-1 %d\n", + printf("#0132:main5-1 %d %d\n",bb0.b[0], main5(bbb,main5(aaa,aaa1)).b[0]); main6();