# HG changeset patch # User kono # Date 1088058103 -32400 # Node ID ce85d61061190dcac957b1f1aab6d06a32d09c35 # Parent f25aa4f03198e2f94eaa68057f31c8fc11aa1b92 bit field continue. (code generation done) diff -r f25aa4f03198 -r ce85d6106119 mc-code-powerpc.c --- a/mc-code-powerpc.c Wed Jun 23 22:37:32 2004 +0900 +++ b/mc-code-powerpc.c Thu Jun 24 15:21:43 2004 +0900 @@ -2970,9 +2970,12 @@ printf("\t.short %d\n",cadr(e)); if (data_alignment>0) data_alignment++; gpc += SIZE_OF_SHORT; - } else { + } else if (t==INT||t==UNSIGNED||(t>0&&car(t)==POINTER)) { printf("\t.long %d\n",cadr(e)); gpc += SIZE_OF_INT; + } else { + // fprintf(stderr,"type= %d\n",t); + error(TYERR); } #if LONGLONG_CODE } else if(t==LONGLONG||t==ULONGLONG) { diff -r f25aa4f03198 -r ce85d6106119 mc-codegen.c --- a/mc-codegen.c Wed Jun 23 22:37:32 2004 +0900 +++ b/mc-codegen.c Thu Jun 24 15:21:43 2004 +0900 @@ -2240,12 +2240,12 @@ } if (mode==GSDECL||mode==LSDECL|| mode==GUDECL||mode==LUDECL) { /* Struct fields name lists are in the struct type or tag. */ - /* Only name in the table is used. */ - if (car(n->ty)==BIT_FIELD) { + /* Only name in the table is used. Do not set n->ty! */ + if (car(type)==BIT_FIELD) { bit_field_disp=sbit_f; // default is 0, recover only here. // n->ty = list4(BIT_FIELD,type,bit_offset,bit_width); - caddr(n->ty) = code_bit_field_disp( - n->ty,&disp,&bit_field_disp,&sz); + caddr(type) = code_bit_field_disp( + type,&disp,&bit_field_disp,&sz); /* bit_field_disp is next bit posision */ } else { sz = size(type); @@ -3173,6 +3173,10 @@ static int bit_field(int e1,int t) { +if (car(e1)==BIT_FIELD) { + printf("# bit_field_bug\n"); + e1 = cadr(e1); +} g_expr(e1); code_bit_field(t, caddr(t) /* bit offset */, USE_CREG); return cadr(t); diff -r f25aa4f03198 -r ce85d6106119 mc-parse.c --- a/mc-parse.c Wed Jun 23 22:37:32 2004 +0900 +++ b/mc-parse.c Thu Jun 24 15:21:43 2004 +0900 @@ -805,8 +805,7 @@ if (mode==GSDECL||mode==GUDECL||mode==LSDECL||mode==LUDECL) { if (scalar(type) || type==LONGLONG || type==ULONGLONG) { getsym(0); - type = n->ty = - list4(BIT_FIELD,type,0 /* bit offset */,symval); + type = list4(BIT_FIELD,type,0 /* bit offset */,symval); getsym(0); } } else @@ -2263,7 +2262,7 @@ return(list3(DPREINC,e,dir)); #endif if(type>0 && car(type)==BIT_FIELD) - return(list3(BPREINC,e,dir)); + return(list4(BPREINC,e,dir,type)); if(car(type)!=POINTER) error(TYERR); return(list4(UPREINC,e, @@ -2410,7 +2409,7 @@ return(list3(LUPOSTINC,e,dir)); #endif if(type>0 && car(type)==BIT_FIELD) - return(list3(BPOSTINC,e,dir)); + return(list4(BPOSTINC,e,dir,type)); if(car(type)!=POINTER) error(TYERR); return(list4(UPOSTINC,e,