Mercurial > hg > CbC > old > device
changeset 885:1a027275743d
struct returinng function have to be indirect.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 05 Apr 2014 21:12:43 +0900 |
parents | f915d5ba033e |
children | 9a4b92984cf1 |
files | mc-parse.c test/tmp7.c |
diffstat | 2 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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();