Mercurial > hg > CbC > old > device
changeset 640:04211a2cf227
*** empty log message ***
author | kono |
---|---|
date | Wed, 01 Nov 2006 01:27:11 +0900 |
parents | f3af9f3332f5 |
children | 90274e6d4d5a |
files | Changes Makefile Makefile.ia32 Makefile.linuxzaurus Makefile.mips Makefile.powerpc mc-codegen.c mc-parse.c test/multi.c |
diffstat | 9 files changed, 72 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Tue Oct 31 22:40:37 2006 +0900 +++ b/Changes Wed Nov 01 01:27:11 2006 +0900 @@ -9024,3 +9024,29 @@ いや、違うな... ARRAY は integral なんじゃないのか? 単なるpointerだろ? 違うの? +大域変数の倍 + array + array +引数の場合 + pointer -> array + pointer -> array + +引数の配列は、ポインタとして扱うわけだが、typedef されている +場合もある。 + +typedef されてなくても、多次元配列の倍数がずれるというバグが +あるらしい。 + +わかった。引数の配列型は、ポインタ型に変換されるのだが、そ +れは、typedef される場合もあるので、def() で行う必要がある。 +また、adecl や decl で処理すると、多次元配列の場合に二回処 +理されてしまう場合があるらしい。 + + + + + + + + + + +
--- a/Makefile Tue Oct 31 22:40:37 2006 +0900 +++ b/Makefile Wed Nov 01 01:27:11 2006 +0900 @@ -111,6 +111,8 @@ make check TARGET=test/putenemy make check TARGET=test/inline make check TARGET=test/offset + make check TARGET=test/ps2 + make check TARGET=test/multi # make check TARGET=test/scope STDFLAG="-std=gnu99" # make check-inline TARGET=test/scope STDFLAG="-std=gnu99" #MK =-make
--- a/Makefile.ia32 Tue Oct 31 22:40:37 2006 +0900 +++ b/Makefile.ia32 Wed Nov 01 01:27:11 2006 +0900 @@ -103,6 +103,8 @@ make check TARGET=test/void_code make check TARGET=test/putenemy make check TARGET=test/inline + make check TARGET=test/ps2 + make check TARGET=test/multi # make check TARGET=test/scope STDFLAG="-std=gnu99" # make check-inline TARGET=test/scope STDFLAG="-std=gnu99" #MK =-make
--- a/Makefile.linuxzaurus Tue Oct 31 22:40:37 2006 +0900 +++ b/Makefile.linuxzaurus Wed Nov 01 01:27:11 2006 +0900 @@ -102,6 +102,8 @@ make check TARGET=test/putenemy make check TARGET=test/inline make check TARGET=test/offset + make check TARGET=test/ps2 + make check TARGET=test/multi # make check TARGET=test/scope STDFLAG="-std=gnu99" # make check-inline TARGET=test/scope STDFLAG="-std=gnu99" #MK =-make
--- a/Makefile.mips Tue Oct 31 22:40:37 2006 +0900 +++ b/Makefile.mips Wed Nov 01 01:27:11 2006 +0900 @@ -100,6 +100,8 @@ make check TARGET=test/void_code make check TARGET=test/putenemy make check TARGET=test/inline + make check TARGET=test/ps2 + make check TARGET=test/multi # make check TARGET=test/scope STDFLAG="-std=gnu99" # make check-inline TARGET=test/scope STDFLAG="-std=gnu99" #MK =-make
--- a/Makefile.powerpc Tue Oct 31 22:40:37 2006 +0900 +++ b/Makefile.powerpc Wed Nov 01 01:27:11 2006 +0900 @@ -111,6 +111,8 @@ make check TARGET=test/putenemy make check TARGET=test/inline make check TARGET=test/offset + make check TARGET=test/ps2 + make check TARGET=test/multi # make check TARGET=test/scope STDFLAG="-std=gnu99" # make check-inline TARGET=test/scope STDFLAG="-std=gnu99" #MK =-make
--- a/mc-codegen.c Tue Oct 31 22:40:37 2006 +0900 +++ b/mc-codegen.c Wed Nov 01 01:27:11 2006 +0900 @@ -3250,9 +3250,16 @@ // scope は parse 時に解決される。 break; case ADECL: // funcion arguments - if(!integral(type0)&&type0>0&&(car(type0)==FUNCTION||car(type0)==CODE)) { - type=list2(POINTER,type); n->ty = type; - type0=type; + if(type0>0) { + if (!integral(type0) && (car(type0)==FUNCTION||car(type0)==CODE)) { + type=list2(POINTER,type); n->ty = type; + sz = size_of_int; + type0=type; + } else if (car(type0)==ARRAY) { + type=list2(POINTER,cadr(type)); n->ty = type; + sz = size_of_int; + type0=type; + } } fnptr->dsp=list4(type,fnptr->dsp,(int)n,0); n->sc = LVAR; @@ -3715,9 +3722,7 @@ { t = type_value(t); return(integral(t) - ||(t>0 && (car(t)==POINTER || - car(t)==ARRAY)) - ); + ||(t>0 && (car(t)==POINTER))); } extern int
--- a/mc-parse.c Tue Oct 31 22:40:37 2006 +0900 +++ b/mc-parse.c Wed Nov 01 01:27:11 2006 +0900 @@ -1120,10 +1120,6 @@ if(sym==IDENT) { if (nptr->sc==TYPE) { t=nptr->ty; - if (mode==ADECL) { - // f(float a[4][4]) case - t = list2(POINTER,t); - } typedefed=glist2((int)nptr,typedefed); getsym(0); break; @@ -1187,7 +1183,7 @@ if(getsym(0)==RBRA) { getsym(0); if(mode==ADECL) { - type=list2(POINTER,type); + type=list3(ARRAY,type,0); } else if (mode==GDECL || stmode==EXTRN) { type=list3(ARRAY,type,0); } else if (mode==GSDECL || mode==LSDECL) { @@ -1258,8 +1254,9 @@ } else error(DCERR); return n; - } else + } else { return n; + } } /* NOT REACHED */ } @@ -1311,7 +1308,7 @@ sargs = args; arg=decl0(); args = sargs; - reverse(t); + reverse(t); // this sets type also if (arg != &null_nptr) { if (smode==GDECL) def(arg,ctmode);
--- a/test/multi.c Tue Oct 31 22:40:37 2006 +0900 +++ b/test/multi.c Wed Nov 01 01:27:11 2006 +0900 @@ -12,17 +12,29 @@ f(ARRAY a) { int i,j; + int b[LEN0][LEN1]; j = a[1][1]; + j = b[1][1]; + for(i=0;i<LEN0;i++) for(j=0;j<LEN1;j++) printf("f %d %d = %d\n",i,j,a[i][j]); + for(i=0;i<LEN0;i++) + for(j=0;j<LEN1;j++) + b[i][j] = i*100 + j; + + for(i=0;i<LEN0;i++) + for(j=0;j<LEN1;j++) + printf("fl %d %d = %d\n",i,j,b[i][j]); } int main() { + int b[LEN0][LEN1]; + int i,j; j = a[1][1]; @@ -34,6 +46,15 @@ for(j=0;j<LEN1;j++) printf("m %d %d = %d\n",i,j,a[i][j]); + for(i=0;i<LEN0;i++) + for(j=0;j<LEN1;j++) + b[i][j] = i*100 + j; + + for(i=0;i<LEN0;i++) + for(j=0;j<LEN1;j++) + printf("l %d %d = %d\n",i,j,b[i][j]); + + f(a); }