# HG changeset patch # User kono # Date 1122706905 -32400 # Node ID 32737bad74893166d2f4e7b5f58df42b79d9ac7a # Parent 7c3d8237b625f9a948136f3e91dd080df14298e2 fix list/tag interference diff -r 7c3d8237b625 -r 32737bad7489 .gdbinit --- a/.gdbinit Mon May 16 11:53:56 2005 +0900 +++ b/.gdbinit Sat Jul 30 16:01:45 2005 +0900 @@ -1,15 +1,3 @@ -tb main -# run -s test/inline.c -# run -s mc-parse.c -# run -s mc-codegen.c -# run -s nkf203/nkf.c -# run -s -ob01.s mc-switch.c -# run -s l.c -# run -s test/const.c -# run -s test/basic.c -# run -s test/code-gen-all.c -# run -s test/tmp7.c -run -s test/inline.c define regs printf "pc =%08x lr =%08x r0 =%08x r1 =%08x r3= %08x r4= %08x\n",$pc,$lr,$r0,$r1,$r3,$r4 printf "r10=%08x r11=%08x r12=%08x r13=%08x r14=%08x r15=%08x\n",$r10,$r11,$r12,$r13,$r14,$r15 @@ -42,3 +30,15 @@ x/1i $pc end b errmsg +tb main +# run -s test/inline.c +run -s mc-parse.c +# run -s mc-codegen.c +# run -s nkf203/nkf.c +# run -s -ob01.s mc-switch.c +# run -s l.c +# run -s test/const.c +# run -s test/basic.c +# run -s test/code-gen-all.c +# run -s test/tmp7.c +# run -s test/inline.c diff -r 7c3d8237b625 -r 32737bad7489 Changes --- a/Changes Mon May 16 11:53:56 2005 +0900 +++ b/Changes Sat Jul 30 16:01:45 2005 +0900 @@ -7163,10 +7163,10 @@ これは.... memcpy なのか。 - - - - - - - +Sat Jul 30 14:41:54 JST 2005 + +あぁ、function の型のlist node にVOIDというprimitive型が入ってしまって +いるね。これは、なんか、やっちまった記憶があるが... + +inline code ってのはありえるの? + diff -r 7c3d8237b625 -r 32737bad7489 Makefile --- a/Makefile Mon May 16 11:53:56 2005 +0900 +++ b/Makefile Sat Jul 30 16:01:45 2005 +0900 @@ -1,4 +1,4 @@ -CC = gcc +CC = gcc -std=c99 # -O3 CFLAGS = -g -Wall -I. # CFLAGS = -g -Wall -I. -pg -fprofile-arcs -ftest-coverage diff -r 7c3d8237b625 -r 32737bad7489 mc-code-powerpc.c --- a/mc-code-powerpc.c Mon May 16 11:53:56 2005 +0900 +++ b/mc-code-powerpc.c Sat Jul 30 16:01:45 2005 +0900 @@ -146,12 +146,12 @@ #define DEBUG_REG 1 #if DEBUG_REG -char *rn(i) { return register_name(i); } -char *fn(i) { return fregister_name(i); } -char *lln(i) { return lregister_name_low(i); } -char *lhn(i) { return lregister_name_high(i); } -int ll(i) { return regv_l(i); } -int lh(i) { return regv_h(i); } +char *rn(int i) { return register_name(i); } +char *fn(int i) { return fregister_name(i); } +char *lln(int i) { return lregister_name_low(i); } +char *lhn(int i) { return lregister_name_high(i); } +int ll(int i) { return regv_l(i); } +int lh(int i) { return regv_h(i); } #endif #define is_int_reg(i) (0<=i&&ity! */ /* Struct field may volatile... where do I put? list2(VOLATILE,type)? */ - if (car(type)==BIT_FIELD) { + if (type>0 && car(type)==BIT_FIELD) { bit_field_disp=sbit_f; // default is 0, recover only here. // type = list4(BIT_FIELD,value type, // list3(store type,bit offset,bit_width)); @@ -2703,7 +2703,7 @@ if (n!=&null_nptr) fields = list4(type,fields,(int)(n->nm),disp); } else if (mode==GUDECL||mode==LUDECL) { - if (car(type)==BIT_FIELD) { + if (type>0 && car(type)==BIT_FIELD) { cadr(caddr(type)) = 0; sz = size(cadr(type)); } else { sz = size(type); @@ -2767,7 +2767,7 @@ ndsp = fwdlabel(); break; case ADECL: - if(!integral(type)&&(car(type)==FUNCTION||car(type)==CODE)) { + if(!integral(type)&&type>0&&(car(type)==FUNCTION||car(type)==CODE)) { type=list2(POINTER,type); n->ty = type; } fnptr->dsp=list4(type,fnptr->dsp,(int)n,0); @@ -3120,7 +3120,9 @@ if(integral(t1)) { if(t1!=t2) error(TYERR); } - else if(car(t1)!=car(t2)) + else if(t1<0 || t2<0) { + if(t1!=t2) error(TYERR); + } else if(car(t1)!=car(t2)) error(TYERR); else if((car(t1)==STRUCT || car(t1)==UNION) && cadr(t1)!=cadr(t2)) error(TYERR); @@ -3131,7 +3133,7 @@ extern int scalar(int t) { - return(integral(t)||car(t)==POINTER); + return(integral(t)||(t>0 && car(t)==POINTER)); } extern int diff -r 7c3d8237b625 -r 32737bad7489 mc-parse.c --- a/mc-parse.c Mon May 16 11:53:56 2005 +0900 +++ b/mc-parse.c Sat Jul 30 16:01:45 2005 +0900 @@ -3110,10 +3110,14 @@ { int e1; e1=list2(FNAME,(int)nptr); - // type=list3(FUNCTION,type,arg); - type=list3(car(nptr->ty),cadr(nptr->ty),caddr(nptr->ty)); + if (nptr->ty>0) { // should be function or code + // type=list3(FUNCTION,type,arg); + type=list3(car(nptr->ty),cadr(nptr->ty),caddr(nptr->ty)); + } else { // label + type=nptr->ty; + } getsym(0); - extrn_use(nptr); + // extrn_use(nptr); can be static return expr16(e1); } @@ -3358,13 +3362,13 @@ /* function call target */ - if(car(type)==POINTER) { + if(type>0 && car(type)==POINTER) { if (car(cadr(type))==FUNCTION||car(cadr(type))==CODE) { e1=rvalue(e1); type=cadr(type); } /* else error */ } - if(integral(type)|| ((car(type)!=FUNCTION)&&(car(type)!=CODE))) { + if(integral(type)||type<0|| ((car(type)!=FUNCTION)&&(car(type)!=CODE))) { error(TYERR); } ftype = type; @@ -3393,7 +3397,7 @@ } checksym(RPAR); conv->funcall_args_(); - if(car(t)==CODE) + if(t<0 && t==CODE) return list4(FUNCTION,e1,arglist,ftype); /* return type */ @@ -3401,7 +3405,7 @@ type = cadr(ftype); if(type==CHAR||type==SHORT) type=INT; else if(type==UCHAR||type==USHORT) type=UNSIGNED; - else if(car(type)==STRUCT||car(type)==UNION) { + else if(type>0 && (car(type)==STRUCT||car(type)==UNION)) { /* make temporary struct for return value */ /* but it is better to see we can reuse old one */ if (tmp_struct) { @@ -3645,7 +3649,7 @@ /* no name copy */ unsigned int ch,i = 0; unsigned int hash0 = 0; - unsigned char *n = name; + char *n = name; struct cheap scheap; save_cheap(&scheap,cheap); @@ -4057,7 +4061,8 @@ nptr_pool = nptr_pool->next; } } - ret = ((NMTBL *)nptr_pool->ptr)++; + ret = (NMTBL *)nptr_pool->ptr; + nptr_pool->ptr += sizeof(NMTBL); ret->sc = 0; ret->ty = 0; ret->dsp = 0; diff -r 7c3d8237b625 -r 32737bad7489 mc.h --- a/mc.h Mon May 16 11:53:56 2005 +0900 +++ b/mc.h Sat Jul 30 16:01:45 2005 +0900 @@ -493,9 +493,9 @@ extern void free_nptr(NMTBL *n); extern NMTBL *get_nptr(); -#if 0 +#if 1 extern int heapsize; -#define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize)error(-1);_k;}) +#define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize||_k<0)error(-1);_k;}) #else #define CHECK_HEAP(b) (b) #endif diff -r 7c3d8237b625 -r 32737bad7489 test/basic.c --- a/test/basic.c Mon May 16 11:53:56 2005 +0900 +++ b/test/basic.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,6 @@ +int printf(const char *format, ...); + + #define ARG_ADDRESS 0 double ggg = 0.134; diff -r 7c3d8237b625 -r 32737bad7489 test/bitfield.c --- a/test/bitfield.c Mon May 16 11:53:56 2005 +0900 +++ b/test/bitfield.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,4 @@ +int printf(const char *format, ...); typedef union { diff -r 7c3d8237b625 -r 32737bad7489 test/bitfield1.c --- a/test/bitfield1.c Mon May 16 11:53:56 2005 +0900 +++ b/test/bitfield1.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,4 @@ +int printf(const char *format, ...); struct aho { int i:1,j:1; diff -r 7c3d8237b625 -r 32737bad7489 test/call.c --- a/test/call.c Mon May 16 11:53:56 2005 +0900 +++ b/test/call.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + int a0(int i); diff -r 7c3d8237b625 -r 32737bad7489 test/cext.c --- a/test/cext.c Mon May 16 11:53:56 2005 +0900 +++ b/test/cext.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,4 @@ +int printf(const char *format, ...); unsigned int u; diff -r 7c3d8237b625 -r 32737bad7489 test/const.c --- a/test/const.c Mon May 16 11:53:56 2005 +0900 +++ b/test/const.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + main() { int i; diff -r 7c3d8237b625 -r 32737bad7489 test/enum.c --- a/test/enum.c Mon May 16 11:53:56 2005 +0900 +++ b/test/enum.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,4 @@ +int printf(const char *format, ...); enum { a,b,c diff -r 7c3d8237b625 -r 32737bad7489 test/long.c --- a/test/long.c Mon May 16 11:53:56 2005 +0900 +++ b/test/long.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + long long gj; long long gi; diff -r 7c3d8237b625 -r 32737bad7489 test/macro.c --- a/test/macro.c Mon May 16 11:53:56 2005 +0900 +++ b/test/macro.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + int heap[100]; diff -r 7c3d8237b625 -r 32737bad7489 test/obsf2.c --- a/test/obsf2.c Mon May 16 11:53:56 2005 +0900 +++ b/test/obsf2.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + typedef struct { char x,y; } s; diff -r 7c3d8237b625 -r 32737bad7489 test/regargs.c --- a/test/regargs.c Mon May 16 11:53:56 2005 +0900 +++ b/test/regargs.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + int arg1(int a1,int a2,int a3,int a4) diff -r 7c3d8237b625 -r 32737bad7489 test/short.c --- a/test/short.c Mon May 16 11:53:56 2005 +0900 +++ b/test/short.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,4 @@ +int printf(const char *format, ...); short gj; short gi; diff -r 7c3d8237b625 -r 32737bad7489 test/simp0.c --- a/test/simp0.c Mon May 16 11:53:56 2005 +0900 +++ b/test/simp0.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + main(int ac,char *av[]) { diff -r 7c3d8237b625 -r 32737bad7489 test/simp1.c --- a/test/simp1.c Mon May 16 11:53:56 2005 +0900 +++ b/test/simp1.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,6 @@ +int printf(const char *format, ...); + + int i(int a,int b,int c,int d,int f) { diff -r 7c3d8237b625 -r 32737bad7489 test/static.c --- a/test/static.c Mon May 16 11:53:56 2005 +0900 +++ b/test/static.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,4 @@ +int printf(const char *format, ...); f() diff -r 7c3d8237b625 -r 32737bad7489 test/strinit.c --- a/test/strinit.c Mon May 16 11:53:56 2005 +0900 +++ b/test/strinit.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,4 @@ +#include int b[3] = {1,2,3}; diff -r 7c3d8237b625 -r 32737bad7489 test/switch.c --- a/test/switch.c Mon May 16 11:53:56 2005 +0900 +++ b/test/switch.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +#include + main(int ac,char *av[]) { int i; diff -r 7c3d8237b625 -r 32737bad7489 test/tmp.c --- a/test/tmp.c Mon May 16 11:53:56 2005 +0900 +++ b/test/tmp.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + int main1(int ac,char *av[],int (*f)(),int g()) diff -r 7c3d8237b625 -r 32737bad7489 test/tmp11.c --- a/test/tmp11.c Mon May 16 11:53:56 2005 +0900 +++ b/test/tmp11.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + typedef struct nametable { char *nm; int sc,ty,dsp; } NMTBL; diff -r 7c3d8237b625 -r 32737bad7489 test/tmp12.c --- a/test/tmp12.c Mon May 16 11:53:56 2005 +0900 +++ b/test/tmp12.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,4 @@ +int printf(const char *format, ...); struct { diff -r 7c3d8237b625 -r 32737bad7489 test/tmp7.c --- a/test/tmp7.c Mon May 16 11:53:56 2005 +0900 +++ b/test/tmp7.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,4 @@ +int printf(const char *format, ...); int k=3; diff -r 7c3d8237b625 -r 32737bad7489 test/tmp8.c --- a/test/tmp8.c Mon May 16 11:53:56 2005 +0900 +++ b/test/tmp8.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + #include int asize = 100; diff -r 7c3d8237b625 -r 32737bad7489 test/void_code.c --- a/test/void_code.c Mon May 16 11:53:56 2005 +0900 +++ b/test/void_code.c Sat Jul 30 16:01:45 2005 +0900 @@ -1,3 +1,5 @@ +int printf(const char *format, ...); + main() { int i;