Mercurial > hg > CbC > old > device
diff mc-parse.c @ 616:2ba903c8e749
builtin_fabs
builtin_inf()
author | kono |
---|---|
date | Wed, 06 Sep 2006 20:58:03 +0900 |
parents | 2dee957ef988 |
children | a7f5796e540a |
line wrap: on
line diff
--- a/mc-parse.c Wed Sep 06 15:21:06 2006 +0900 +++ b/mc-parse.c Wed Sep 06 20:58:03 2006 +0900 @@ -610,6 +610,12 @@ reserve("__builtin_alloca",ALLOCA); reserve("__builtin_constant_p",BUILTINP); reserve("__builtin_expect",BUILTIN_EXPECT); + reserve("__builtin_fabs",BUILTIN_FABS); + reserve("__builtin_fabsf",BUILTIN_FABSF); + reserve("__builtin_fabsl",BUILTIN_FABSL); + reserve("__builtin_inf",BUILTIN_INF); + reserve("__builtin_inff",BUILTIN_INFF); + reserve("__builtin_infl",BUILTIN_INFL); reserve("__attribute__",ATTRIBUTE); reserve("__attribute",ATTRIBUTE); reserve("__label__",LABEL); @@ -619,6 +625,7 @@ reserve("__LINE__",C_LINE); #if ASM_CODE reserve("asm",ASM); + reserve("__asm",ASM); // ? reserve("__asm__",ASM); #endif @@ -1497,8 +1504,10 @@ return offset; } t1 = caddr(type0); /* list of fields */ - if (sym==LC) getsym(0); - else if (sym==LPAR) { + if (sym==LC) { + mode = STAT; + getsym(0); + } else if (sym==LPAR) { // have to be a value, no comma cascading values // .__tcp_lhash_lock = (rwlock_t) { }, // We cannot this distinguish this case and cascading comma here. @@ -1560,6 +1569,7 @@ mode=STADECL; nptr0=new_static_name("__lstruct",'_'); def(nptr0,0); + mode=smode; //nptr0->next = local_static_list; local_static_list = nptr0; //nptr0->sc = STATIC; //nptr0->ty = t = type; @@ -2998,7 +3008,15 @@ if (sym!=STRING) error(DCERR); asm0=list3(STRING,(int)nptr,nptr->dsp); getsym(0); - if (sym!=COLON) error(DCERR); + if (sym!=COLON) { +#if 0 + if (sym==RPAR) { + // old type asm statement + goto output; + } +#endif + error(DCERR); + } do { // output expression getsym(0); @@ -3478,6 +3496,52 @@ checksym(RPAR); type=t; return e; + case BUILTIN_FABSF: + conv->prefix_(sym); + getsym(0); + checksym(LPAR); + e=expr0(); + checksym(RPAR); + e = list2(op,rvalue_t(e,FLOAT)); + type = FLOAT; + if (is_const(e)) { +#if FLOAT_CODE + return (dcadr(e)>0.0) ? dcadr(e) : dlist2(FCONST,-dcadr(e)); +#endif + } + return e; + case BUILTIN_FABS: + case BUILTIN_FABSL: + conv->prefix_(sym); + getsym(0); + checksym(LPAR); + e=expr0(); + checksym(RPAR); + e = list2(op,rvalue_t(e,DOUBLE)); + type = DOUBLE; + if (is_const(e)) { +#if FLOAT_CODE + return (dcadr(e)>0.0) ? dcadr(e) : dlist2(DCONST,-dcadr(e)); +#endif + } + return e; + case BUILTIN_INFF: + conv->prefix_(sym); + getsym(0); + checksym(LPAR); + checksym(RPAR); + type = FLOAT; + e = list2(op,0); + return e; + case BUILTIN_INF: + case BUILTIN_INFL: + conv->prefix_(sym); + getsym(0); + checksym(LPAR); + checksym(RPAR); + type = DOUBLE; + e = list2(op,0); + return e; case SIZEOF: conv->prefix_(sym); if(getsym(0)==LPAR) { @@ -3797,11 +3861,11 @@ mode=STADECL; def(nptr0,0); e1 = size(type); + mode = smode; decl_data_field(type,nptr0,0); conv->rc_(); checksym(RC); e1 = list3(RSTRUCT,list3(GVAR,0,(int)nptr0),e1); - mode = smode; return e1; } e1=expr13(); @@ -4471,6 +4535,13 @@ getch(); } } + /* C99 */ + if (ch=='F' || ch=='L') { + // float or long double + *cheap->ptr = ch; + cheap = increment_cheap(cheap,&num); + getch(); + } *cheap->ptr = 0; cheap = increment_cheap(cheap,&num); dsymval = strtod(num,0);