Mercurial > hg > CbC > old > device
changeset 332:ce85d6106119
bit field continue. (code generation done)
author | kono |
---|---|
date | Thu, 24 Jun 2004 15:21:43 +0900 |
parents | f25aa4f03198 |
children | bd3e6eff7d41 |
files | mc-code-powerpc.c mc-codegen.c mc-parse.c |
diffstat | 3 files changed, 15 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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) {
--- 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);
--- 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,