PulkoMandy | 17fc759 | 2022-07-28 18:27:54 +0200 | [diff] [blame] | 1 | /* $VER: vbcc (type_expr.c) $Revision: 1.64 $ */ |
| 2 | |
| 3 | #include "vbc.h" |
| 4 | |
| 5 | static char FILE_[]=__FILE__; |
| 6 | |
| 7 | #define CONSTADDR 256 |
| 8 | |
| 9 | |
| 10 | /* if MASK is set, a specialized version will be generated */ |
| 11 | #define USEHALF (1L<<1) |
| 12 | #define USELONG (1L<<2) |
| 13 | #define USELLONG (1L<<3) |
| 14 | #define USEFLOAT (1L<<4) |
| 15 | #define USEHEXL (1L<<5) |
| 16 | #define USEHEXU (1L<<6) |
| 17 | #define USEDEC (1L<<7) |
| 18 | #define USEOCT (1L<<8) |
| 19 | #define USEINT (1L<<9) |
| 20 | #define USEUNS (1L<<10) |
| 21 | #define USESTR (1L<<11) |
| 22 | #define USECHAR (1L<<12) |
| 23 | #define USEPERC (1L<<13) |
| 24 | #define USECNT (1L<<14) |
| 25 | #define USEALT (1L<<15) |
| 26 | #define USEZPAD (1L<<16) |
| 27 | #define USELALGN (1L<<17) |
| 28 | #define USEBLANK (1L<<18) |
| 29 | #define USESIGN (1L<<19) |
| 30 | #define USEWIDTH (1L<<20) |
| 31 | #define USEAST (1L<<21) |
| 32 | #define USEPREC (1L<<22) |
| 33 | #define USESPEC (1L<<23) |
| 34 | #define USEREXP (1L<<24) |
| 35 | |
| 36 | int alg_opt(np,type *); |
| 37 | void simple_alg_opt(np); |
| 38 | int test_assignment(type *,np); |
| 39 | int type_expression2(np,type *); |
| 40 | void make_cexpr(np); |
| 41 | |
| 42 | int dontopt; |
| 43 | int no_cast_free; |
| 44 | |
| 45 | type uct={UNSIGNED|CHAR}; |
| 46 | type ust={UNSIGNED|SHORT}; |
| 47 | type uit={UNSIGNED|INT}; |
| 48 | type ult={UNSIGNED|LONG}; |
| 49 | |
| 50 | #ifdef HAVE_ECPP |
| 51 | /* removed */ |
| 52 | /* removed */ |
| 53 | /* removed */ |
| 54 | /* removed */ |
| 55 | /* removed */ |
| 56 | /* removed */ |
| 57 | /* removed */ |
| 58 | /* removed */ |
| 59 | /* removed */ |
| 60 | /* removed */ |
| 61 | /* removed */ |
| 62 | /* removed */ |
| 63 | #endif |
| 64 | |
| 65 | #ifdef HAVE_MISRA |
| 66 | /* removed */ |
| 67 | /* removed */ |
| 68 | /* removed */ |
| 69 | /* removed */ |
| 70 | /* removed */ |
| 71 | /* removed */ |
| 72 | /* removed */ |
| 73 | /* removed */ |
| 74 | /* removed */ |
| 75 | /* removed */ |
| 76 | /* removed */ |
| 77 | /* removed */ |
| 78 | /* removed */ |
| 79 | /* removed */ |
| 80 | /* removed */ |
| 81 | /* removed */ |
| 82 | /* removed */ |
| 83 | /* removed */ |
| 84 | /* removed */ |
| 85 | /* removed */ |
| 86 | /* removed */ |
| 87 | /* removed */ |
| 88 | /* removed */ |
| 89 | /* removed */ |
| 90 | /* removed */ |
| 91 | /* removed */ |
| 92 | /* removed */ |
| 93 | /* removed */ |
| 94 | /* removed */ |
| 95 | /* removed */ |
| 96 | /* removed */ |
| 97 | /* removed */ |
| 98 | /* removed */ |
| 99 | /* removed */ |
| 100 | /* removed */ |
| 101 | /* removed */ |
| 102 | /* removed */ |
| 103 | /* removed */ |
| 104 | /* removed */ |
| 105 | /* removed */ |
| 106 | /* removed */ |
| 107 | /* removed */ |
| 108 | /* removed */ |
| 109 | /* removed */ |
| 110 | /* removed */ |
| 111 | /* removed */ |
| 112 | /* removed */ |
| 113 | /* removed */ |
| 114 | /* removed */ |
| 115 | /* removed */ |
| 116 | /* removed */ |
| 117 | /* removed */ |
| 118 | /* removed */ |
| 119 | /* removed */ |
| 120 | /* removed */ |
| 121 | /* removed */ |
| 122 | /* removed */ |
| 123 | /* removed */ |
| 124 | /* removed */ |
| 125 | /* removed */ |
| 126 | /* removed */ |
| 127 | /* removed */ |
| 128 | /* removed */ |
| 129 | /* removed */ |
| 130 | /* removed */ |
| 131 | /* removed */ |
| 132 | /* removed */ |
| 133 | /* removed */ |
| 134 | /* removed */ |
| 135 | /* removed */ |
| 136 | /* removed */ |
| 137 | /* removed */ |
| 138 | /* removed */ |
| 139 | /* removed */ |
| 140 | /* removed */ |
| 141 | /* removed */ |
| 142 | /* removed */ |
| 143 | /* removed */ |
| 144 | /* removed */ |
| 145 | /* removed */ |
| 146 | /* removed */ |
| 147 | /* removed */ |
| 148 | /* removed */ |
| 149 | /* removed */ |
| 150 | /* removed */ |
| 151 | /* removed */ |
| 152 | /* removed */ |
| 153 | /* removed */ |
| 154 | /* removed */ |
| 155 | /* removed */ |
| 156 | /* removed */ |
| 157 | /* removed */ |
| 158 | /* removed */ |
| 159 | /* removed */ |
| 160 | /* removed */ |
| 161 | /* removed */ |
| 162 | /* removed */ |
| 163 | /* removed */ |
| 164 | /* removed */ |
| 165 | /* removed */ |
| 166 | /* removed */ |
| 167 | /* removed */ |
| 168 | /* removed */ |
| 169 | /* removed */ |
| 170 | /* removed */ |
| 171 | /* removed */ |
| 172 | /* removed */ |
| 173 | /* removed */ |
| 174 | /* removed */ |
| 175 | /* removed */ |
| 176 | /* removed */ |
| 177 | /* removed */ |
| 178 | /* removed */ |
| 179 | /* removed */ |
| 180 | /* removed */ |
| 181 | /* removed */ |
| 182 | /* removed */ |
| 183 | /* removed */ |
| 184 | /* removed */ |
| 185 | /* removed */ |
| 186 | /* removed */ |
| 187 | /* removed */ |
| 188 | /* removed */ |
| 189 | /* removed */ |
| 190 | /* removed */ |
| 191 | /* removed */ |
| 192 | /* removed */ |
| 193 | /* removed */ |
| 194 | /* removed */ |
| 195 | /* removed */ |
| 196 | /* removed */ |
| 197 | /* removed */ |
| 198 | /* removed */ |
| 199 | /* removed */ |
| 200 | /* removed */ |
| 201 | /* removed */ |
| 202 | /* removed */ |
| 203 | /* removed */ |
| 204 | /* removed */ |
| 205 | /* removed */ |
| 206 | /* removed */ |
| 207 | /* removed */ |
| 208 | /* removed */ |
| 209 | /* removed */ |
| 210 | /* removed */ |
| 211 | /* removed */ |
| 212 | /* removed */ |
| 213 | /* removed */ |
| 214 | /* removed */ |
| 215 | /* removed */ |
| 216 | /* removed */ |
| 217 | /* removed */ |
| 218 | /* removed */ |
| 219 | /* removed */ |
| 220 | /* removed */ |
| 221 | /* removed */ |
| 222 | /* removed */ |
| 223 | /* removed */ |
| 224 | /* removed */ |
| 225 | /* removed */ |
| 226 | /* removed */ |
| 227 | /* removed */ |
| 228 | /* removed */ |
| 229 | /* removed */ |
| 230 | /* removed */ |
| 231 | /* removed */ |
| 232 | /* removed */ |
| 233 | /* removed */ |
| 234 | /* removed */ |
| 235 | /* removed */ |
| 236 | /* removed */ |
| 237 | /* removed */ |
| 238 | /* removed */ |
| 239 | /* removed */ |
| 240 | /* removed */ |
| 241 | /* removed */ |
| 242 | /* removed */ |
| 243 | /* removed */ |
| 244 | /* removed */ |
| 245 | /* removed */ |
| 246 | /* removed */ |
| 247 | /* removed */ |
| 248 | /* removed */ |
| 249 | /* removed */ |
| 250 | /* removed */ |
| 251 | /* removed */ |
| 252 | /* removed */ |
| 253 | /* removed */ |
| 254 | /* removed */ |
| 255 | /* removed */ |
| 256 | /* removed */ |
| 257 | /* removed */ |
| 258 | /* removed */ |
| 259 | /* removed */ |
| 260 | /* removed */ |
| 261 | /* removed */ |
| 262 | /* removed */ |
| 263 | /* removed */ |
| 264 | /* removed */ |
| 265 | /* removed */ |
| 266 | /* removed */ |
| 267 | /* removed */ |
| 268 | /* removed */ |
| 269 | /* removed */ |
| 270 | /* removed */ |
| 271 | /* removed */ |
| 272 | /* removed */ |
| 273 | /* removed */ |
| 274 | /* removed */ |
| 275 | /* removed */ |
| 276 | /* removed */ |
| 277 | /* removed */ |
| 278 | /* removed */ |
| 279 | /* removed */ |
| 280 | /* removed */ |
| 281 | /* removed */ |
| 282 | /* removed */ |
| 283 | /* removed */ |
| 284 | /* removed */ |
| 285 | /* removed */ |
| 286 | /* removed */ |
| 287 | /* removed */ |
| 288 | /* removed */ |
| 289 | /* removed */ |
| 290 | /* removed */ |
| 291 | /* removed */ |
| 292 | /* removed */ |
| 293 | /* removed */ |
| 294 | /* removed */ |
| 295 | /* removed */ |
| 296 | /* removed */ |
| 297 | /* removed */ |
| 298 | /* removed */ |
| 299 | /* removed */ |
| 300 | /* removed */ |
| 301 | /* removed */ |
| 302 | /* removed */ |
| 303 | /* removed */ |
| 304 | /* removed */ |
| 305 | /* removed */ |
| 306 | /* removed */ |
| 307 | /* removed */ |
| 308 | /* removed */ |
| 309 | /* removed */ |
| 310 | /* removed */ |
| 311 | /* removed */ |
| 312 | /* removed */ |
| 313 | /* removed */ |
| 314 | /* removed */ |
| 315 | /* removed */ |
| 316 | /* removed */ |
| 317 | /* removed */ |
| 318 | /* removed */ |
| 319 | /* removed */ |
| 320 | /* removed */ |
| 321 | /* removed */ |
| 322 | /* removed */ |
| 323 | /* removed */ |
| 324 | /* removed */ |
| 325 | /* removed */ |
| 326 | /* removed */ |
| 327 | /* removed */ |
| 328 | /* removed */ |
| 329 | /* removed */ |
| 330 | /* removed */ |
| 331 | /* removed */ |
| 332 | /* removed */ |
| 333 | /* removed */ |
| 334 | /* removed */ |
| 335 | /* removed */ |
| 336 | /* removed */ |
| 337 | /* removed */ |
| 338 | /* removed */ |
| 339 | /* removed */ |
| 340 | /* removed */ |
| 341 | /* removed */ |
| 342 | /* removed */ |
| 343 | /* removed */ |
| 344 | /* removed */ |
| 345 | /* removed */ |
| 346 | /* removed */ |
| 347 | /* removed */ |
| 348 | /* removed */ |
| 349 | /* removed */ |
| 350 | /* removed */ |
| 351 | /* removed */ |
| 352 | /* removed */ |
| 353 | /* removed */ |
| 354 | /* removed */ |
| 355 | /* removed */ |
| 356 | /* removed */ |
| 357 | /* removed */ |
| 358 | /* removed */ |
| 359 | /* removed */ |
| 360 | /* removed */ |
| 361 | /* removed */ |
| 362 | /* removed */ |
| 363 | /* removed */ |
| 364 | /* removed */ |
| 365 | /* removed */ |
| 366 | /* removed */ |
| 367 | /* removed */ |
| 368 | /* removed */ |
| 369 | /* removed */ |
| 370 | /* removed */ |
| 371 | /* removed */ |
| 372 | /* removed */ |
| 373 | /* removed */ |
| 374 | /* removed */ |
| 375 | /* removed */ |
| 376 | /* removed */ |
| 377 | /* removed */ |
| 378 | /* removed */ |
| 379 | /* removed */ |
| 380 | /* removed */ |
| 381 | #endif |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | void insert_constn(np p) |
| 388 | /* Spezialfall fuer np */ |
| 389 | { |
| 390 | if(!p||!p->ntyp) ierror(0); |
| 391 | insert_const(&p->val,p->ntyp->flags); |
| 392 | } |
| 393 | int const_typ(type *p) |
| 394 | /* Testet, ob Typ konstant ist oder konstante Elemente enthaelt */ |
| 395 | { |
| 396 | int i;struct_declaration *sd; |
| 397 | if(p->flags&CONST) return(1); |
| 398 | if(ISSTRUCT(p->flags)||ISUNION(p->flags)) |
| 399 | for(i=0;i<p->exact->count;i++) |
| 400 | if(const_typ((*p->exact->sl)[i].styp)) return(1); |
| 401 | return 0; |
| 402 | } |
| 403 | int arith_flag(int ta,int tb) |
| 404 | { |
| 405 | /* TODO: volatile? */ |
| 406 | ta&=NU;tb&=NU; |
| 407 | if(ta==LDOUBLE||tb==LDOUBLE) return LDOUBLE; |
| 408 | if(ta==DOUBLE||tb==DOUBLE) return DOUBLE; |
| 409 | if(ta==FLOAT||tb==FLOAT) return FLOAT; |
| 410 | ta=int_erw(ta);tb=int_erw(tb); |
| 411 | if(ta==(UNSIGNED|LLONG)||tb==(UNSIGNED|LLONG)) return UNSIGNED|LLONG; |
| 412 | if(ta==LLONG||tb==LLONG) return LLONG; |
| 413 | if(ta==(UNSIGNED|LONG)||tb==(UNSIGNED|LONG)) return UNSIGNED|LONG; |
| 414 | if((ta==LONG&&tb==(UNSIGNED|INT))||(ta==(UNSIGNED|INT)&&tb==LONG)){ |
| 415 | if(zumleq(t_max(UNSIGNED|INT),t_max(LONG))) |
| 416 | return LONG; |
| 417 | else |
| 418 | return UNSIGNED|LONG; |
| 419 | } |
| 420 | if(ta==LONG||tb==LONG) return LONG; |
| 421 | if(ta==(UNSIGNED|INT)||tb==(UNSIGNED|INT)) return UNSIGNED|INT; |
| 422 | return INT; |
| 423 | } |
| 424 | |
| 425 | type *arith_typ(type *a,type *b) |
| 426 | /* Erzeugt Typ fuer arithmetische Umwandlung von zwei Operanden */ |
| 427 | { |
| 428 | int ta,tb,va,vol;type *new; |
| 429 | new=new_typ(); |
| 430 | ta=a->flags&NU;tb=b->flags&NU; |
| 431 | vol=(a->flags&VOLATILE)|(b->flags&VOLATILE); |
| 432 | if(ta==LDOUBLE||tb==LDOUBLE){new->flags=LDOUBLE|vol;return new;} |
| 433 | if(ta==DOUBLE||tb==DOUBLE){new->flags=DOUBLE|vol;return new;} |
| 434 | if(ta==FLOAT||tb==FLOAT){new->flags=FLOAT|vol;return new;} |
| 435 | ta=int_erw(ta);tb=int_erw(tb); |
| 436 | if(ta==(UNSIGNED|LLONG)||tb==(UNSIGNED|LLONG)){new->flags=UNSIGNED|LLONG|vol;return new;} |
| 437 | if(ta==LLONG||tb==LLONG){new->flags=LLONG|vol;return new;} |
| 438 | if(ta==(UNSIGNED|LONG)||tb==(UNSIGNED|LONG)){new->flags=UNSIGNED|LONG|vol;return new;} |
| 439 | if((ta==LONG&&tb==(UNSIGNED|INT))||(ta==(UNSIGNED|INT)&&tb==LONG)){ |
| 440 | if(zumleq(t_max(UNSIGNED|INT),t_max(LONG))) new->flags=LONG|vol; else new->flags=UNSIGNED|LONG|vol; |
| 441 | return new; |
| 442 | } |
| 443 | if(ta==LONG||tb==LONG){new->flags=LONG|vol;return new;} |
| 444 | if(ta==(UNSIGNED|INT)||tb==(UNSIGNED|INT)){new->flags=UNSIGNED|INT|vol;return new;} |
| 445 | new->flags=INT|vol; |
| 446 | return new; |
| 447 | } |
| 448 | int int_erw(int t) |
| 449 | /* Fuehrt Integer_Erweiterung eines Typen durch */ |
| 450 | { |
| 451 | if((t&NQ)>=INT) return t; |
| 452 | if(t&UNSIGNED){ |
| 453 | if((t&NQ)<=CHAR&&zumleq(t_max(UNSIGNED|CHAR),t_max(INT))) return INT; |
| 454 | if((t&NQ)<=SHORT&&zumleq(t_max(UNSIGNED|SHORT),t_max(INT))) return INT; |
| 455 | return UNSIGNED|INT; |
| 456 | } |
| 457 | return INT; |
| 458 | } |
| 459 | #if HAVE_AOS4 |
| 460 | static int aos4err; |
| 461 | int aos4_attr(type *p,char *s) |
| 462 | { |
| 463 | if(p->attr&&strstr(p->attr,s)) |
| 464 | return 1; |
| 465 | if(p->next) |
| 466 | return aos4_attr(p->next,s); |
| 467 | else |
| 468 | return 0; |
| 469 | } |
| 470 | static np aos4_clone_tree(np p) |
| 471 | { |
| 472 | np new; |
| 473 | if(!p) return 0; |
| 474 | new=new_node(); |
| 475 | *new=*p; |
| 476 | new->ntyp=clone_typ(p->ntyp); |
| 477 | new->left=aos4_clone_tree(p->left); |
| 478 | new->right=aos4_clone_tree(p->right); |
| 479 | new->alist=0;new->cl=0;new->dsize=0; |
| 480 | if(p->flags==CALL/*||p->cl||p->dsize*/) aos4err=1; |
| 481 | return new; |
| 482 | } |
| 483 | #endif |
| 484 | #ifdef HAVE_MISRA |
| 485 | /* removed */ |
| 486 | /* removed */ |
| 487 | /* removed */ |
| 488 | /* removed */ |
| 489 | /* removed */ |
| 490 | /* removed */ |
| 491 | /* removed */ |
| 492 | /* removed */ |
| 493 | /* removed */ |
| 494 | /* removed */ |
| 495 | /* removed */ |
| 496 | /* removed */ |
| 497 | /* removed */ |
| 498 | /* removed */ |
| 499 | /* removed */ |
| 500 | /* removed */ |
| 501 | /* removed */ |
| 502 | /* removed */ |
| 503 | /* removed */ |
| 504 | /* removed */ |
| 505 | /* removed */ |
| 506 | /* removed */ |
| 507 | /* removed */ |
| 508 | /* removed */ |
| 509 | /* removed */ |
| 510 | /* removed */ |
| 511 | /* removed */ |
| 512 | /* removed */ |
| 513 | /* removed */ |
| 514 | /* removed */ |
| 515 | /* removed */ |
| 516 | #endif |
| 517 | int type_expression(np p,type *ttyp) |
| 518 | /* Art Frontend fuer type_expression2(). Setzt dontopt auf 0 */ |
| 519 | { |
| 520 | int ret_val; |
| 521 | dontopt=0; |
| 522 | simple_alg_opt(p); |
| 523 | #ifdef HAVE_MISRA |
| 524 | /* removed */ |
| 525 | /* removed */ |
| 526 | /* removed */ |
| 527 | /* removed */ |
| 528 | #endif |
| 529 | ret_val = type_expression2(p,ttyp); |
| 530 | #ifdef HAVE_MISRA |
| 531 | /* removed */ |
| 532 | #endif |
| 533 | return ret_val; |
| 534 | |
| 535 | } |
| 536 | |
| 537 | static void fix_addr_ptype(np op) |
| 538 | { |
| 539 | np p=op; |
| 540 | while(p->flags==FIRSTELEMENT) p=p->left; |
| 541 | if(p->left->flags==CONTENT){ |
| 542 | int pt=p->left->left->ntyp->flags; |
| 543 | if(!ISPOINTER(pt)) ierror(0); |
| 544 | if(!ISPOINTER(op->ntyp->flags)) ierror(0); |
| 545 | op->ntyp->flags=pt; |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | static int ptype(np op) |
| 550 | { |
| 551 | #ifdef POINTER_VARADR |
| 552 | Var *v=0; |
| 553 | np p=op; |
| 554 | |
| 555 | while(p->flags==FIRSTELEMENT/*||p->flags==CONTENT*/) p=p->left; |
| 556 | |
| 557 | if(p->flags==IDENTIFIER) |
| 558 | v=find_var(p->identifier,0); |
| 559 | if(v) |
| 560 | return POINTER_VARADR(v); |
| 561 | else |
| 562 | return POINTER_TYPE(op->ntyp); |
| 563 | #else |
| 564 | return POINTER_TYPE(op->ntyp); |
| 565 | #endif |
| 566 | } |
| 567 | |
| 568 | static int decide_shortcut(np p,type *ttyp) |
| 569 | { |
| 570 | int ttf=ttyp->flags,f=p->flags; |
| 571 | if(f==PMULT) f=MULT; |
| 572 | if(!shortcut(f,ttyp->flags&NU)|| |
| 573 | ISFLOAT(ttf)||ISFLOAT(p->left->ntyp->flags)||ISFLOAT(p->right->ntyp->flags) |
| 574 | ) |
| 575 | return 0; |
| 576 | ttf&=NQ; |
| 577 | if(ttf<INT) return 1; |
| 578 | if(zm2l(sizetab[ttf])<zm2l(sizetab[(p->left->ntyp->flags&NQ)])) return 1; |
| 579 | if(zm2l(sizetab[ttf])<zm2l(sizetab[(p->right->ntyp->flags&NQ)])) return 1; |
| 580 | return 0; |
| 581 | } |
| 582 | |
| 583 | |
| 584 | |
| 585 | static type *best_addi2pt(zmax sz) |
| 586 | { |
| 587 | if(!zmeqto(sizetab[CHAR],sizetab[INT])&&!zmeqto(sz,Z0)&&MINADDI2P<=CHAR&&zumleq(zm2zum(sz),zumadd(tu_max[CHAR],ZU1))){ |
| 588 | return &uct; |
| 589 | }else if(!zmeqto(sizetab[SHORT],sizetab[INT])&&!zmeqto(sz,Z0)&&MINADDI2P<=SHORT&&zumleq(zm2zum(sz),zumadd(tu_max[SHORT],ZU1))){ |
| 590 | return &ust; |
| 591 | } |
| 592 | return 0; |
| 593 | } |
| 594 | |
| 595 | type *andcomp(np and,np cmp) |
| 596 | { |
| 597 | int i=0;zmax sval;zumax uval; |
| 598 | if(cmp){ |
| 599 | if((cmp->flags==CEXPR||cmp->flags==PCEXPR)){i=1;eval_constn(cmp);sval=vmax;uval=vumax;} |
| 600 | }else{ |
| 601 | sval=Z0;uval=ZU0; |
| 602 | i=1; |
| 603 | } |
| 604 | if(and->flags==AND&&(and->left->flags==CEXPR||and->left->flags==PCEXPR)){i|=2;eval_constn(and->left);} |
| 605 | if(and->flags==AND&&(and->right->flags==CEXPR||and->right->flags==PCEXPR)){i|=2;eval_constn(and->right);} |
| 606 | if(i&2){ |
| 607 | /*printf("CHECK: x&%ld ==/!= %ld\n",zm2l(vmax),(i&1)?zm2l(sval):-1L);*/ |
| 608 | if(shortcut(COMPARE,UNSIGNED|CHAR)&&shortcut(AND,UNSIGNED|CHAR)&&!zmeqto(sizetab[CHAR],sizetab[SHORT])){ |
| 609 | if(zmleq(vmax,t_max[CHAR])) |
| 610 | return &uct; |
| 611 | else if((i&1)&&zumleq(vumax,tu_max[CHAR])&&zumleq(uval,tu_max[CHAR])) |
| 612 | return &uct; |
| 613 | } |
| 614 | if(shortcut(COMPARE,UNSIGNED|SHORT)&&shortcut(AND,UNSIGNED|SHORT)&&!zmeqto(sizetab[SHORT],sizetab[INT])){ |
| 615 | if(zmleq(vmax,t_max[SHORT])) |
| 616 | return &ust; |
| 617 | else if((i&1)&&zumleq(vumax,tu_max[SHORT])&&zumleq(uval,tu_max[SHORT])) |
| 618 | return &ust; |
| 619 | } |
| 620 | if(!zmeqto(sizetab[INT],sizetab[LONG])){ |
| 621 | if(zmleq(vmax,t_max[INT])) |
| 622 | return &uit; |
| 623 | else if((i&1)&&zumleq(vumax,tu_max[INT])&&zumleq(uval,tu_max[INT])) |
| 624 | return &uit; |
| 625 | } |
| 626 | if(!zmeqto(sizetab[LONG],sizetab[LLONG])){ |
| 627 | if(zmleq(vmax,t_max[LONG])) |
| 628 | return &ult; |
| 629 | else if((i&1)&&zumleq(vumax,tu_max[LONG])&&zumleq(uval,tu_max[LONG])) |
| 630 | return &ult; |
| 631 | } |
| 632 | } |
| 633 | return 0; |
| 634 | } |
| 635 | |
| 636 | static int nullpointer(np p) |
| 637 | { |
| 638 | if(p->flags!=CEXPR) return 0; |
| 639 | eval_constn(p); /* TODO: do we need to use other measure to verify null pointer? */ |
| 640 | if(zmeqto(Z0,vmax)) return 1; |
| 641 | return 0; |
| 642 | } |
| 643 | |
| 644 | int type_expression2(np p,type *ttyp) |
| 645 | /* Erzeugt Typ-Strukturen fuer jeden Knoten des Baumes und */ |
| 646 | /* liefert eins zurueck, wenn der Baum ok ist, sonst 0 */ |
| 647 | /* Die Berechnung von Konstanten und andere Vereinfachungen */ |
| 648 | /* sollten vielleicht in eigene Funktion kommen */ |
| 649 | { |
| 650 | int ok,f=p->flags,mopt=dontopt,ttf; |
| 651 | type *shorttyp; |
| 652 | static int assignop; |
| 653 | int aoflag; |
| 654 | #if HAVE_AOS4 |
| 655 | np thisp=0; |
| 656 | #endif |
| 657 | #ifdef HAVE_ECPP |
| 658 | /* removed */ |
| 659 | /* removed */ |
| 660 | /* removed */ |
| 661 | /* removed */ |
| 662 | #endif |
| 663 | if(!p){ierror(0);return(1);} |
| 664 | if(ttyp) ttf=ttyp->flags&NQ; |
| 665 | /* if(p->ntyp) printf("Warnung: ntyp!=0\n");*/ |
| 666 | p->lvalue=0; |
| 667 | p->sidefx=0; |
| 668 | ok=1; |
| 669 | if(!ecpp&&f==CALL&&p->left->flags==IDENTIFIER&&!find_var(p->left->identifier,0)){ |
| 670 | /* implizite Deklaration bei Aufruf einer Funktion */ |
| 671 | struct_declaration *sd;type *t;Var *v; |
| 672 | #ifdef HAVE_MISRA |
| 673 | /* removed */ |
| 674 | #endif |
| 675 | error(161,p->left->identifier); |
| 676 | if(v=find_ext_var(p->left->identifier)){ |
| 677 | if(!ISFUNC(v->vtyp->flags)||v->vtyp->next->flags!=INT){ |
| 678 | error(68,p->left->identifier); |
| 679 | #ifdef HAVE_MISRA |
| 680 | /* removed */ |
| 681 | #endif |
| 682 | } |
| 683 | v->flags&=~NOTINTU; |
| 684 | }else{ |
| 685 | sd=mymalloc(sizeof(*sd)); |
| 686 | sd->count=0; |
| 687 | t=new_typ(); |
| 688 | t->flags=FUNKT; |
| 689 | t->exact=add_sd(sd,FUNKT); |
| 690 | t->next=new_typ(); |
| 691 | t->next->flags=INT; |
| 692 | add_var(p->left->identifier,t,EXTERN,0); |
| 693 | } |
| 694 | } |
| 695 | #if HAVE_AOS4 |
| 696 | if(f==CALL&&p->left->flags==DSTRUCT){ |
| 697 | thisp=new_node(); |
| 698 | thisp->flags=ADDRESS; |
| 699 | aos4err=0; |
| 700 | thisp->left=aos4_clone_tree(p->left->left); |
| 701 | thisp->right=0; |
| 702 | thisp->alist=0;thisp->cl=0;thisp->dsize=0;thisp->ntyp=0; |
| 703 | } |
| 704 | #endif |
| 705 | #if HAVE_ECPP |
| 706 | if(ecpp&&f==CALL){ |
| 707 | argument_list *al=p->alist; |
| 708 | if(al/*&&!al->arg->ntyp*/){ |
| 709 | while(al){ |
| 710 | if(!al->arg) ierror(0); |
| 711 | if(!type_expression2(al->arg,0)) return 0; |
| 712 | al->arg=makepointer(al->arg); |
| 713 | if(type_uncomplete(al->arg->ntyp)) error(39); |
| 714 | al=al->next; |
| 715 | } |
| 716 | } |
| 717 | } |
| 718 | if(ecpp&&f==CALL){ |
| 719 | ecpp_merk_al=ecpp_al; |
| 720 | ecpp_al=p->alist; |
| 721 | } |
| 722 | #endif |
| 723 | dontopt=0; |
| 724 | if(f==ADDRESS&&p->left->flags==IDENTIFIER) {p->left->flags|=CONSTADDR;/*puts("&const");*/} |
| 725 | if(ttyp&&(f==OR||f==AND||f==XOR||f==ADD||f==SUB||f==MULT||f==PMULT||f==DIV||f==MOD||f==KOMPLEMENT||f==MINUS)&&!ISPOINTER(ttyp->flags)&&shortcut(f==PMULT?MULT:f,ttyp->flags&NU)) |
| 726 | shorttyp=ttyp; |
| 727 | else |
| 728 | shorttyp=0; |
| 729 | if(assignop){ |
| 730 | aoflag=1; |
| 731 | assignop=0; |
| 732 | }else |
| 733 | aoflag=0; |
| 734 | |
| 735 | if(!shorttyp){ |
| 736 | if(f==EQUAL||f==INEQUAL){ |
| 737 | if(p->left->flags==AND) shorttyp=andcomp(p->left,p->right); |
| 738 | if(p->right->flags==AND) shorttyp=andcomp(p->right,p->left); |
| 739 | } |
| 740 | } |
| 741 | if(!shorttyp&&(f==LAND||f==LOR)&&p->left->flags==AND) shorttyp=andcomp(p->left,0); |
| 742 | if(p->left&&p->flags!=ASSIGNOP){ |
| 743 | struct_declaration *sd; |
| 744 | /* bei ASSIGNOP wird der linke Zweig durch den Link bewertet */ |
| 745 | if(!p->left) ierror(0); |
| 746 | if(p->flags==CAST) |
| 747 | ok&=type_expression2(p->left,p->ntyp); |
| 748 | else |
| 749 | ok&=type_expression2(p->left,shorttyp); |
| 750 | if(p->left) p->sidefx|=p->left->sidefx; |
| 751 | if(!ok) return 0; |
| 752 | } |
| 753 | if(aoflag){ |
| 754 | if(!p->left||!p->right) ierror(0); |
| 755 | shorttyp=p->left->ntyp; |
| 756 | ttyp=shorttyp; |
| 757 | ttf=ttyp->flags&NQ; |
| 758 | } |
| 759 | |
| 760 | if(f==LAND||f==LOR){ |
| 761 | shorttyp=0; |
| 762 | if(p->right->flags==AND) shorttyp=andcomp(p->right,0); |
| 763 | } |
| 764 | |
| 765 | if(f==ADD){ |
| 766 | if(p->left->flags==ADDRESSS||p->left->flags==ADDRESSA||p->left->flags==ADDRESSS){ |
| 767 | zmax sz=szof(p->left->left->ntyp); |
| 768 | shorttyp=best_addi2pt(sz); |
| 769 | } |
| 770 | if((p->left->ntyp->flags&NQ)==ARRAY){ |
| 771 | zmax sz=szof(p->left->ntyp); |
| 772 | shorttyp=best_addi2pt(sz); |
| 773 | if(shorttyp){ |
| 774 | np new=new_node(); |
| 775 | new->flags=CAST; |
| 776 | new->ntyp=clone_typ(shorttyp); |
| 777 | new->left=p->right; |
| 778 | p->right=new; |
| 779 | } |
| 780 | } |
| 781 | } |
| 782 | if(p->right&&p->right->flags!=MEMBER){ |
| 783 | struct_declaration *sd; |
| 784 | if(p->flags==ASSIGNOP){ |
| 785 | dontopt=1; |
| 786 | assignop=1; |
| 787 | }else |
| 788 | dontopt=0; |
| 789 | if(p->flags==ASSIGN) |
| 790 | ok&=type_expression2(p->right,p->left->ntyp); |
| 791 | else |
| 792 | ok&=type_expression2(p->right,shorttyp); |
| 793 | p->sidefx|=p->right->sidefx; |
| 794 | if(!ok) return 0; |
| 795 | } |
| 796 | #if HAVE_AOS4 |
| 797 | if(thisp){ |
| 798 | if(aos4_attr(p->left->ntyp,"libcall")){ |
| 799 | argument_list *n=mymalloc(sizeof(*n)); |
| 800 | n->arg=thisp; |
| 801 | n->next=p->alist; |
| 802 | n->pushic=0; |
| 803 | p->alist=n; |
| 804 | if(aos4err) {pre(stdout,thisp);ierror(0);} |
| 805 | }else{ |
| 806 | free_expression(thisp); |
| 807 | } |
| 808 | } |
| 809 | #endif |
| 810 | #if HAVE_ECPP |
| 811 | if(ecpp&&f==CALL){ |
| 812 | ecpp_al=ecpp_merk_al; |
| 813 | } |
| 814 | #endif |
| 815 | /* printf("bearbeite %s\n",ename[p->flags]);*/ |
| 816 | /* Erzeugung von Zeigern aus Arrays */ |
| 817 | /* Hier muss noch einiges genauer werden (wie gehoert das?) */ |
| 818 | if(p->left&&f!=PCEXPR&&(ISARRAY(p->left->ntyp->flags)||ISFUNC(p->left->ntyp->flags))){ |
| 819 | if(f!=ADDRESS&&f!=ADDRESSA&&f!=ADDRESSS&&f!=FIRSTELEMENT&&f!=DSTRUCT&&(f<PREINC||f>POSTDEC)&&(f<ASSIGN||f>ASSIGNOP)){ |
| 820 | np new=new_node(); |
| 821 | zmax sz=szof(p->left->ntyp); |
| 822 | if((p->left->ntyp->flags&NQ)==ARRAY) new->flags=ADDRESSA; |
| 823 | else new->flags=ADDRESS; |
| 824 | new->ntyp=0; |
| 825 | new->left=p->left; |
| 826 | new->right=0;new->lvalue=0;new->sidefx=0; /* sind sidefx immer 0? */ |
| 827 | p->left=new; |
| 828 | ok&=type_expression2(p->left,0); |
| 829 | } |
| 830 | } |
| 831 | if(p->right&&f!=PCEXPR&&f!=FIRSTELEMENT&&f!=DSTRUCT&&f!=ADDRESSS&&p->right->ntyp&&(ISARRAY(p->right->ntyp->flags)||ISFUNC(p->right->ntyp->flags))){ |
| 832 | np new=new_node(); |
| 833 | if(ISARRAY(p->right->ntyp->flags)) new->flags=ADDRESSA; |
| 834 | else new->flags=ADDRESS; |
| 835 | new->ntyp=0; |
| 836 | new->left=p->right; |
| 837 | new->right=0;new->lvalue=0;new->sidefx=0; /* sind sidefx immer 0? */ |
| 838 | p->right=new; |
| 839 | ok&=type_expression2(p->right,0); |
| 840 | } |
| 841 | |
| 842 | if(f==IDENTIFIER||f==(IDENTIFIER|CONSTADDR)){ |
| 843 | int ff;Var *v; |
| 844 | #ifdef HAVE_ECPP |
| 845 | /* removed */ |
| 846 | /* removed */ |
| 847 | /* removed */ |
| 848 | /* removed */ |
| 849 | /* removed */ |
| 850 | /* removed */ |
| 851 | /* removed */ |
| 852 | /* removed */ |
| 853 | /* removed */ |
| 854 | /* removed */ |
| 855 | /* removed */ |
| 856 | /* removed */ |
| 857 | /* removed */ |
| 858 | /* removed */ |
| 859 | /* removed */ |
| 860 | /* removed */ |
| 861 | /* removed */ |
| 862 | /* removed */ |
| 863 | /* removed */ |
| 864 | /* removed */ |
| 865 | /* removed */ |
| 866 | /* removed */ |
| 867 | /* removed */ |
| 868 | /* removed */ |
| 869 | /* removed */ |
| 870 | /* removed */ |
| 871 | /* removed */ |
| 872 | /* removed */ |
| 873 | /* removed */ |
| 874 | /* removed */ |
| 875 | /* removed */ |
| 876 | /* removed */ |
| 877 | /* removed */ |
| 878 | /* removed */ |
| 879 | /* removed */ |
| 880 | /* removed */ |
| 881 | /* removed */ |
| 882 | /* removed */ |
| 883 | /* removed */ |
| 884 | /* removed */ |
| 885 | /* removed */ |
| 886 | /* removed */ |
| 887 | /* removed */ |
| 888 | /* removed */ |
| 889 | /* removed */ |
| 890 | /* removed */ |
| 891 | /* removed */ |
| 892 | /* removed */ |
| 893 | /* removed */ |
| 894 | /* removed */ |
| 895 | /* removed */ |
| 896 | /* removed */ |
| 897 | /* removed */ |
| 898 | /* removed */ |
| 899 | /* removed */ |
| 900 | /* removed */ |
| 901 | /* removed */ |
| 902 | /* removed */ |
| 903 | /* removed */ |
| 904 | /* removed */ |
| 905 | /* removed */ |
| 906 | /* removed */ |
| 907 | /* removed */ |
| 908 | /* removed */ |
| 909 | /* removed */ |
| 910 | /* removed */ |
| 911 | /* removed */ |
| 912 | /* removed */ |
| 913 | /* removed */ |
| 914 | /* removed */ |
| 915 | /* removed */ |
| 916 | /* removed */ |
| 917 | /* removed */ |
| 918 | #endif |
| 919 | if(!ecpp){ |
| 920 | if(p->identifier==empty) |
| 921 | /* variable sizeof-expression */ |
| 922 | v=p->dsize; |
| 923 | else{ |
| 924 | char buf[20]; |
| 925 | v=find_var(p->identifier,0); |
| 926 | if(v&&v->storage_class==EXTERN){ |
| 927 | if(!strcmp(p->identifier,"strtod")){sprintf(buf,"vfscanf.%ld",1|USEFLOAT);needs(buf);} |
| 928 | if(!strcmp(p->identifier,"strtof")){sprintf(buf,"vscanf.%ld",1|USEFLOAT);needs(buf);} |
| 929 | if(!strcmp(p->identifier,"atof")){sprintf(buf,"vscanf.%ld",1|USEFLOAT);needs(buf);} |
| 930 | if(!strcmp(p->identifier,"tmpnam")){sprintf(buf,"vfprintf.%ld",1|USEDEC);needs(buf);} |
| 931 | if(!strcmp(p->identifier,"fopen")){ |
| 932 | needs("__read.2"); |
| 933 | needs("__write.2"); |
| 934 | needs("stdin.2"); |
| 935 | needs("stdout.2"); |
| 936 | needs("stderr.2"); |
| 937 | } |
| 938 | } |
| 939 | } |
| 940 | } |
| 941 | if(v==0){error(82,p->identifier);return(0);} |
| 942 | if(disallow_statics&&v->storage_class==STATIC&&v->nesting==0&&*v->identifier){ |
| 943 | error(302,v->identifier); |
| 944 | return 0; |
| 945 | } |
| 946 | ff=v->vtyp->flags&NQ; |
| 947 | if(ISARITH(ff)||ISPOINTER(ff)||ISSTRUCT(ff)||ISUNION(ff)||ISVECTOR(ff)) p->lvalue=1; |
| 948 | p->ntyp=clone_typ(v->vtyp); |
| 949 | /* arithmetischen const Typ als Konstante behandeln, das muss noch |
| 950 | deutlich anders werden, bevor man es wirklich so machen kann |
| 951 | if((p->ntyp->flags&CONST)&&ISARITH(p->ntyp->flags)&&v->clist&&!(f&CONSTADDR)){ |
| 952 | p->flags=CEXPR; |
| 953 | p->val=v->clist->val; |
| 954 | v->flags|=USEDASSOURCE; |
| 955 | }*/ |
| 956 | p->flags&=~CONSTADDR; |
| 957 | if((p->ntyp->flags&NQ)==ENUM){ |
| 958 | /* enumerations auch als Konstante (int) behandeln */ |
| 959 | p->flags=CEXPR; |
| 960 | if(!v->clist) ierror(0); |
| 961 | p->val=v->clist->val; |
| 962 | p->ntyp->flags=CONST|INT; |
| 963 | } |
| 964 | p->o.v=v; |
| 965 | if (p->ntyp->flags&VOLATILE) p->sidefx=1; /* Touching a volatile may have side effects */ |
| 966 | return 1; |
| 967 | } |
| 968 | |
| 969 | if(f==CEXPR||f==PCEXPR||f==STRING) return 1; |
| 970 | |
| 971 | if(f==REINTERPRET){ |
| 972 | /* todo: add checks */ |
| 973 | return 1; |
| 974 | } |
| 975 | |
| 976 | if(f==BITFIELD) return 1; |
| 977 | |
| 978 | if(f==LITERAL){ |
| 979 | p->lvalue=1; |
| 980 | return 1; |
| 981 | } |
| 982 | |
| 983 | if(f==KOMMA){ |
| 984 | if(const_expr){error(46);return 0;} |
| 985 | p->ntyp=clone_typ(p->right->ntyp); |
| 986 | if(f==CEXPR) p->val=p->right->val; |
| 987 | return ok; |
| 988 | } |
| 989 | if(f==ASSIGN||f==ASSIGNOP){ |
| 990 | if(!p) ierror(0); |
| 991 | if(!p->left) ierror(0); |
| 992 | if(p->left->lvalue==0) {error(86);/*prd(p->left->ntyp);*/return 0;} |
| 993 | if(const_typ(p->left->ntyp)) {error(87);return 0;} |
| 994 | if(type_uncomplete(p->left->ntyp)) {error(88);return 0;} |
| 995 | if(type_uncomplete(p->right->ntyp)) {error(88);return 0;} |
| 996 | p->ntyp=clone_typ(p->left->ntyp); |
| 997 | p->sidefx=1; |
| 998 | return(test_assignment(p->left->ntyp,p->right)); |
| 999 | } |
| 1000 | if(f==LOR||f==LAND){ |
| 1001 | int a1=-1,a2=-1,m; |
| 1002 | if(ISVECTOR(p->left->ntyp->flags)){ |
| 1003 | if(ISVECTOR(p->right->ntyp->flags)){ |
| 1004 | if((p->left->ntyp->flags&NU)!=(p->right->ntyp->flags&NU)){error(89);return 0;} |
| 1005 | }else{ |
| 1006 | if(!ISINT(p->right->ntyp->flags)){error(89);return 0;} |
| 1007 | } |
| 1008 | p->ntyp=new_typ(); |
| 1009 | p->ntyp->flags=p->left->ntyp->flags&NQ; |
| 1010 | return ok; |
| 1011 | } |
| 1012 | if(ISVECTOR(p->right->ntyp->flags)){ |
| 1013 | if(!ISINT(p->left->ntyp->flags)){error(89);return 0;} |
| 1014 | p->ntyp->flags=p->right->ntyp->flags&NQ; |
| 1015 | return ok; |
| 1016 | } |
| 1017 | if(f==LAND) m=1; else m=0; |
| 1018 | #ifdef HAVE_MISRA |
| 1019 | /* removed */ |
| 1020 | #endif |
| 1021 | p->ntyp=new_typ(); |
| 1022 | p->ntyp->flags=INT; |
| 1023 | if(!ISARITH(p->left->ntyp->flags)&&!ISPOINTER(p->left->ntyp->flags)) |
| 1024 | {error(89);ok=0;} |
| 1025 | if(!ISARITH(p->right->ntyp->flags)&&!ISPOINTER(p->right->ntyp->flags)) |
| 1026 | {error(89);ok=0;} |
| 1027 | if(p->left->flags==CEXPR){ |
| 1028 | eval_constn(p->left); |
| 1029 | if(!zldeqto(vldouble,d2zld(0.0))||!zumeqto(vumax,ul2zum(0UL))||!zmeqto(vmax,l2zm(0L))) a1=1; else a1=0; |
| 1030 | } |
| 1031 | if(p->right->flags==CEXPR){ |
| 1032 | eval_constn(p->right); |
| 1033 | if(!zldeqto(vldouble,d2zld(0.0))||!zumeqto(vumax,ul2zum(0UL))||!zmeqto(vmax,l2zm(0L))) a2=1; else a2=0; |
| 1034 | } |
| 1035 | if(a1==1-m||a2==1-m||(a1==m&&a2==m)){ |
| 1036 | p->flags=CEXPR;p->sidefx=0; |
| 1037 | if(!p->left->sidefx) {free_expression(p->left);p->left=0;} else p->sidefx=1; |
| 1038 | if(!p->right->sidefx||a1==1-m) {free_expression(p->right);p->right=0;} else p->sidefx=0; |
| 1039 | if(a1==1-m||a2==1-m) {p->val.vint=zm2zi(l2zm((long)(1-m)));} |
| 1040 | else {p->val.vint=zm2zi(l2zm((long)m));} |
| 1041 | } |
| 1042 | return ok; |
| 1043 | } |
| 1044 | if(f==OR||f==AND||f==XOR){ |
| 1045 | if(ISVECTOR(p->left->ntyp->flags)){ |
| 1046 | if(!ISINT(VECTYPE(p->left->ntyp->flags))){error(90);return 0;} |
| 1047 | if(ISVECTOR(p->right->ntyp->flags)){ |
| 1048 | if((p->left->ntyp->flags&NU)!=(p->right->ntyp->flags&NU)){error(98);return 0;} |
| 1049 | }else{ |
| 1050 | if(!ISINT(p->right->ntyp->flags)){error(90);return 0;} |
| 1051 | } |
| 1052 | p->ntyp=clone_typ(p->left->ntyp); |
| 1053 | return ok; |
| 1054 | } |
| 1055 | if(ISVECTOR(p->right->ntyp->flags)){ |
| 1056 | if(!ISINT(VECTYPE(p->right->ntyp->flags))){error(90);return 0;} |
| 1057 | if(!ISINT(p->left->ntyp->flags)){error(90);return 0;} |
| 1058 | p->ntyp=clone_typ(p->right->ntyp); |
| 1059 | return ok; |
| 1060 | } |
| 1061 | if(!ISINT(p->left->ntyp->flags)){error(90);return 0;} |
| 1062 | if(!ISINT(p->right->ntyp->flags)){error(90);return 0;} |
| 1063 | #ifdef HAVE_MISRA |
| 1064 | /* removed */ |
| 1065 | /* removed */ |
| 1066 | #endif |
| 1067 | if(ttyp&&decide_shortcut(p,ttyp)) |
| 1068 | p->ntyp=clone_typ(ttyp); |
| 1069 | else |
| 1070 | p->ntyp=arith_typ(p->left->ntyp,p->right->ntyp); |
| 1071 | if(!mopt){ |
| 1072 | if(!alg_opt(p,ttyp)) ierror(0); |
| 1073 | } |
| 1074 | return ok; |
| 1075 | } |
| 1076 | if(f==LESS||f==LESSEQ||f==GREATER||f==GREATEREQ||f==EQUAL||f==INEQUAL){ |
| 1077 | /* hier noch einige Abfragen fuer sichere Entscheidungen einbauen */ |
| 1078 | /* z.B. unigned/signed-Vergleiche etc. */ |
| 1079 | /* die val.vint=0/1-Zuweisungen muessen noch an zint angepasst */ |
| 1080 | /* werden */ |
| 1081 | zmax s1,s2;zumax u1,u2;zldouble d1,d2;int c=0; |
| 1082 | type *t; |
| 1083 | if(ISVECTOR(p->left->ntyp->flags)){ |
| 1084 | if(ISVECTOR(p->right->ntyp->flags)){ |
| 1085 | if((p->left->ntyp->flags&NU)!=(p->right->ntyp->flags&NU)){error(89);return 0;} |
| 1086 | } |
| 1087 | p->ntyp=new_typ(); |
| 1088 | if(ISFLOAT(VECTYPE(p->left->ntyp->flags))) |
| 1089 | p->ntyp->flags=mkvec(INT,VECDIM(p->left->ntyp->flags)); |
| 1090 | else |
| 1091 | p->ntyp->flags=p->left->ntyp->flags&NQ; |
| 1092 | return ok; |
| 1093 | } |
| 1094 | if(ISVECTOR(p->right->ntyp->flags)){ |
| 1095 | p->ntyp=new_typ(); |
| 1096 | if(ISFLOAT(VECTYPE(p->right->ntyp->flags))) |
| 1097 | p->ntyp->flags=mkvec(INT,VECDIM(p->left->ntyp->flags)); |
| 1098 | else |
| 1099 | p->ntyp->flags=p->right->ntyp->flags&NQ; |
| 1100 | return ok; |
| 1101 | } |
| 1102 | #ifdef HAVE_MISRA |
| 1103 | /* removed */ |
| 1104 | /* removed */ |
| 1105 | /* removed */ |
| 1106 | /* removed */ |
| 1107 | #endif |
| 1108 | if(!ISARITH(p->left->ntyp->flags)||!ISARITH(p->right->ntyp->flags)){ |
| 1109 | if(!ISPOINTER(p->left->ntyp->flags)||!ISPOINTER(p->right->ntyp->flags)){ |
| 1110 | if(f!=EQUAL&&f!=INEQUAL){ |
| 1111 | error(92);return 0; |
| 1112 | }else{ |
| 1113 | if((!ISPOINTER(p->left->ntyp->flags)||p->right->flags!=CEXPR)&& |
| 1114 | (!ISPOINTER(p->right->ntyp->flags)||p->left->flags!=CEXPR)){ |
| 1115 | error(93);return 0; |
| 1116 | }else{ |
| 1117 | if(p->left->flags==CEXPR) eval_constn(p->left); |
| 1118 | else eval_constn(p->right); |
| 1119 | if(!zldeqto(vldouble,d2zld(0.0))||!zmeqto(vmax,l2zm(0L))||!zumeqto(vumax,ul2zum(0UL))) |
| 1120 | {error(40);return 0;} |
| 1121 | } |
| 1122 | } |
| 1123 | }else{ |
| 1124 | if(compatible_types(p->left->ntyp->next,p->right->ntyp->next,NQ)){ |
| 1125 | }else{ |
| 1126 | if(f!=EQUAL&&f!=INEQUAL) error(41); |
| 1127 | if((p->left->ntyp->next->flags&NQ)!=VOID&&(p->right->ntyp->next->flags&NQ)!=VOID) |
| 1128 | {error(41);} |
| 1129 | } |
| 1130 | } |
| 1131 | } |
| 1132 | if(p->left->flags==CEXPR){ |
| 1133 | eval_constn(p->left); |
| 1134 | d1=vldouble;u1=vumax;s1=vmax;c|=1; |
| 1135 | if((p->right->ntyp->flags&UNSIGNED)&&!(p->left->ntyp->flags&UNSIGNED)){ |
| 1136 | if(zldleq(d1,d2zld(0.0))&&zmleq(s1,l2zm(0L))){ |
| 1137 | if(!zldeqto(d1,d2zld(0.0))||!zmeqto(s1,l2zm(0L))){ |
| 1138 | if(zumleq(tu_max[p->right->ntyp->flags&NQ],t_max[p->left->ntyp->flags&NQ])) |
| 1139 | error(165); |
| 1140 | }else{ |
| 1141 | if(f==GREATER||f==LESSEQ) error(165); |
| 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | } |
| 1146 | if(p->right->flags==CEXPR){ |
| 1147 | eval_constn(p->right); |
| 1148 | d2=vldouble;u2=vumax;s2=vmax;c|=2; |
| 1149 | if((p->left->ntyp->flags&UNSIGNED)&&!(p->right->ntyp->flags&UNSIGNED)){ |
| 1150 | if(zldleq(d2,d2zld(0.0))&&zmleq(s2,l2zm(0L))){ |
| 1151 | if(!zldeqto(d2,d2zld(0.0))||!zmeqto(s2,l2zm(0L))){ |
| 1152 | if(zumleq(tu_max[p->left->ntyp->flags&NQ],t_max[p->right->ntyp->flags&NQ])) |
| 1153 | error(165); |
| 1154 | }else{ |
| 1155 | if(f==LESS||f==GREATEREQ) error(165); |
| 1156 | } |
| 1157 | } |
| 1158 | } |
| 1159 | } |
| 1160 | p->ntyp=new_typ(); |
| 1161 | p->ntyp->flags=INT; |
| 1162 | if(c==3){ |
| 1163 | p->flags=CEXPR; |
| 1164 | t=arith_typ(p->left->ntyp,p->right->ntyp); |
| 1165 | if(!p->left->sidefx) {free_expression(p->left);p->left=0;} |
| 1166 | if(!p->right->sidefx) {free_expression(p->right);p->right=0;} |
| 1167 | if(ISFLOAT(t->flags)){ |
| 1168 | if(f==EQUAL) p->val.vint=zm2zi(l2zm((long)zldeqto(d1,d2))); |
| 1169 | if(f==INEQUAL) p->val.vint=zm2zi(l2zm((long)!zldeqto(d1,d2))); |
| 1170 | if(f==LESSEQ) p->val.vint=zm2zi(l2zm((long)zldleq(d1,d2))); |
| 1171 | if(f==GREATER) p->val.vint=zm2zi(l2zm((long)!zldleq(d1,d2))); |
| 1172 | if(f==LESS){ |
| 1173 | if(zldleq(d1,d2)&&!zldeqto(d1,d2)) |
| 1174 | p->val.vint=zm2zi(l2zm(1L)); |
| 1175 | else |
| 1176 | p->val.vint=zm2zi(l2zm(0L)); |
| 1177 | } |
| 1178 | if(f==GREATEREQ){ |
| 1179 | if(!zldleq(d1,d2)||zldeqto(d1,d2)) |
| 1180 | p->val.vint=zm2zi(l2zm(1L)); |
| 1181 | else |
| 1182 | p->val.vint=zm2zi(l2zm(0L)); |
| 1183 | } |
| 1184 | }else{ |
| 1185 | if(t->flags&UNSIGNED){ |
| 1186 | if(f==EQUAL) p->val.vint=zm2zi(l2zm((long)zumeqto(u1,u2))); |
| 1187 | if(f==INEQUAL) p->val.vint=zm2zi(l2zm((long)!zumeqto(u1,u2))); |
| 1188 | if(f==LESSEQ) p->val.vint=zm2zi(l2zm((long)zumleq(u1,u2))); |
| 1189 | if(f==GREATER) p->val.vint=zm2zi(l2zm((long)!zumleq(u1,u2))); |
| 1190 | if(f==LESS){ |
| 1191 | if(zumleq(u1,u2)&&!zumeqto(u1,u2)) |
| 1192 | p->val.vint=zm2zi(l2zm(1L)); |
| 1193 | else |
| 1194 | p->val.vint=zm2zi(l2zm(0L)); |
| 1195 | } |
| 1196 | if(f==GREATEREQ){ |
| 1197 | if(!zumleq(u1,u2)||zumeqto(u1,u2)) |
| 1198 | p->val.vint=zm2zi(l2zm(1L)); |
| 1199 | else |
| 1200 | p->val.vint=zm2zi(l2zm(0L)); |
| 1201 | } |
| 1202 | }else{ |
| 1203 | if(f==EQUAL) p->val.vint=zm2zi(l2zm((long)zmeqto(s1,s2))); |
| 1204 | if(f==INEQUAL) p->val.vint=zm2zi(l2zm((long)!zmeqto(s1,s2))); |
| 1205 | if(f==LESSEQ) p->val.vint=zm2zi(l2zm((long)zmleq(s1,s2))); |
| 1206 | if(f==GREATER) p->val.vint=zm2zi(l2zm((long)!zmleq(s1,s2))); |
| 1207 | if(f==LESS){ |
| 1208 | if(zmleq(s1,s2)&&!zmeqto(s1,s2)) |
| 1209 | p->val.vint=zm2zi(l2zm(1L)); |
| 1210 | else |
| 1211 | p->val.vint=zm2zi(l2zm(0L)); |
| 1212 | } |
| 1213 | if(f==GREATEREQ){ |
| 1214 | if(!zmleq(s1,s2)||zmeqto(s1,s2)) |
| 1215 | p->val.vint=zm2zi(l2zm(1L)); |
| 1216 | else |
| 1217 | p->val.vint=zm2zi(l2zm(0L)); |
| 1218 | } |
| 1219 | } |
| 1220 | } |
| 1221 | freetyp(t); |
| 1222 | } |
| 1223 | return ok; |
| 1224 | } |
| 1225 | if(f==ADD||f==SUB||f==MULT||f==DIV||f==MOD||f==LSHIFT||f==RSHIFT||f==PMULT){ |
| 1226 | if(ISVECTOR(p->left->ntyp->flags)){ |
| 1227 | if((f==MOD||f==LSHIFT||f==RSHIFT)&&ISFLOAT(VECTYPE(p->left->ntyp->flags))){ |
| 1228 | error(98); |
| 1229 | return 0; |
| 1230 | } |
| 1231 | if(ISARITH(p->right->ntyp->flags)){ |
| 1232 | p->ntyp=clone_typ(p->left->ntyp); |
| 1233 | return ok; |
| 1234 | } |
| 1235 | if((p->left->ntyp->flags&NU)==(p->right->ntyp->flags&NU)){ |
| 1236 | p->ntyp=clone_typ(p->left->ntyp); |
| 1237 | return ok; |
| 1238 | } |
| 1239 | error(98); |
| 1240 | return 0; |
| 1241 | } |
| 1242 | if(ISVECTOR(p->right->ntyp->flags)){ |
| 1243 | if((f==MOD||f==LSHIFT||f==RSHIFT)&&ISFLOAT(VECTYPE(p->right->ntyp->flags))){ |
| 1244 | error(98); |
| 1245 | return 0; |
| 1246 | } |
| 1247 | if(ISARITH(p->left->ntyp->flags)){ |
| 1248 | p->ntyp=clone_typ(p->right->ntyp); |
| 1249 | return ok; |
| 1250 | } |
| 1251 | error(98); |
| 1252 | return 0; |
| 1253 | } |
| 1254 | if(!ISARITH(p->left->ntyp->flags)||!ISARITH(p->right->ntyp->flags)){ |
| 1255 | np new;zmax sz; int typf=0; |
| 1256 | #ifdef MAXADDI2P |
| 1257 | static type pmt={MAXADDI2P}; |
| 1258 | #endif |
| 1259 | if(f!=ADD&&f!=SUB){error(94);return 0;} |
| 1260 | #ifdef HAVE_MISRA |
| 1261 | /* removed */ |
| 1262 | /* removed */ |
| 1263 | #endif |
| 1264 | if(ISPOINTER(p->left->ntyp->flags)){ |
| 1265 | if((p->left->ntyp->next->flags&NQ)==VOID) |
| 1266 | {error(95);return 0;} |
| 1267 | if(ISPOINTER(p->right->ntyp->flags)){ |
| 1268 | if((p->right->ntyp->next->flags&NQ)==VOID) |
| 1269 | {error(95);return 0;} |
| 1270 | if(!compatible_types(p->left->ntyp->next,p->right->ntyp->next,NQ)) |
| 1271 | {error(41);} |
| 1272 | if(f!=SUB){ |
| 1273 | error(96); |
| 1274 | return 0; |
| 1275 | }else{ |
| 1276 | typf=3; |
| 1277 | } |
| 1278 | }else{ |
| 1279 | if(!ISINT(p->right->ntyp->flags)) |
| 1280 | {error(97,ename[f]);return 0;} |
| 1281 | if(p->right->flags!=PMULT&&p->right->flags!=PCEXPR){ |
| 1282 | new=new_node(); |
| 1283 | new->flags=PMULT; |
| 1284 | new->ntyp=0; |
| 1285 | new->left=p->right; |
| 1286 | new->right=new_node(); |
| 1287 | if(is_vlength(p->left->ntyp->next)){ |
| 1288 | new->right->flags=IDENTIFIER; |
| 1289 | new->right->identifier=empty; |
| 1290 | new->right->dsize=vlength_szof(p->left->ntyp->next); |
| 1291 | new->right->val.vmax=l2zm(0L); |
| 1292 | new->right->sidefx=0; |
| 1293 | }else{ |
| 1294 | new->right->flags=PCEXPR; |
| 1295 | sz=szof(p->left->ntyp->next); |
| 1296 | if(zmeqto(l2zm(0L),sz)) error(78); |
| 1297 | #if HAVE_INT_SIZET |
| 1298 | new->right->val.vint=zm2zi(sz); |
| 1299 | #else |
| 1300 | new->right->val.vlong=zm2zl(sz); |
| 1301 | #endif |
| 1302 | } |
| 1303 | new->right->left=new->right->right=0; |
| 1304 | new->right->ntyp=new_typ(); |
| 1305 | #if HAVE_INT_SIZET |
| 1306 | new->right->ntyp->flags=INT; |
| 1307 | #else |
| 1308 | new->right->ntyp->flags=LONG; |
| 1309 | #endif |
| 1310 | p->right=new; |
| 1311 | #ifdef MAXADDI2P |
| 1312 | ok&=type_expression2(new,(shorttyp&&(shorttyp->flags&NQ)<MAXADDI2P)?shorttyp:&pmt); |
| 1313 | #else |
| 1314 | ok&=type_expression2(new,shorttyp); |
| 1315 | #endif |
| 1316 | } |
| 1317 | typf=1; |
| 1318 | } |
| 1319 | }else{ |
| 1320 | np merk; |
| 1321 | if(!ISPOINTER(p->right->ntyp->flags)) |
| 1322 | {error(98);return 0;} |
| 1323 | if((p->right->ntyp->next->flags&NQ)==VOID) |
| 1324 | {error(95);return 0;} |
| 1325 | if(!ISINT(p->left->ntyp->flags)) |
| 1326 | {error(98);return 0;} |
| 1327 | if(p->flags==SUB){error(99);return 0;} |
| 1328 | if(p->left->flags!=PMULT&&p->left->flags!=PCEXPR){ |
| 1329 | new=new_node(); |
| 1330 | new->flags=PMULT; |
| 1331 | new->ntyp=0; |
| 1332 | new->left=p->left; |
| 1333 | new->right=new_node(); |
| 1334 | if(is_vlength(p->right->ntyp->next)){ |
| 1335 | new->right->flags=IDENTIFIER; |
| 1336 | new->right->identifier=empty; |
| 1337 | new->right->dsize=vlength_szof(p->right->ntyp->next); |
| 1338 | new->right->val.vmax=l2zm(0L); |
| 1339 | new->right->sidefx=0; |
| 1340 | }else{ |
| 1341 | new->right->flags=PCEXPR; |
| 1342 | sz=szof(p->right->ntyp->next); |
| 1343 | if(zmeqto(l2zm(0L),sz)) error(78); |
| 1344 | #if HAVE_INT_SIZET |
| 1345 | new->right->val.vint=zm2zi(sz); |
| 1346 | #else |
| 1347 | new->right->val.vlong=zm2zl(sz); |
| 1348 | #endif |
| 1349 | } |
| 1350 | new->right->left=new->right->right=0; |
| 1351 | new->right->ntyp=new_typ(); |
| 1352 | #if HAVE_INT_SIZET |
| 1353 | new->right->ntyp->flags=INT; |
| 1354 | #else |
| 1355 | new->right->ntyp->flags=LONG; |
| 1356 | #endif |
| 1357 | p->left=new; |
| 1358 | #ifdef MAXADDI2P |
| 1359 | ok&=type_expression2(new,&pmt); |
| 1360 | #else |
| 1361 | ok&=type_expression2(new,0); |
| 1362 | #endif |
| 1363 | } |
| 1364 | typf=2; |
| 1365 | merk=p->left;p->left=p->right;p->right=merk; |
| 1366 | } |
| 1367 | if(typf==0){ierror(0);return(0);} |
| 1368 | else{ |
| 1369 | if(typf==3){ |
| 1370 | p->ntyp=new_typ(); |
| 1371 | p->ntyp->flags=PTRDIFF_T(p->left->ntyp->flags); |
| 1372 | }else{ |
| 1373 | /*if(typf==1)*/ p->ntyp=clone_typ(p->left->ntyp); |
| 1374 | /* else p->ntyp=clone_typ(p->right->ntyp);*/ |
| 1375 | /* Abfrage wegen Vertauschen der Knoten unnoetig */ |
| 1376 | } |
| 1377 | } |
| 1378 | }else{ |
| 1379 | if(f==LSHIFT||f==RSHIFT){ |
| 1380 | if(ttyp&&f==LSHIFT&&(ttf<=INT||ttf<(p->left->ntyp->flags&NQ))&&shortcut(f,ttyp->flags&NU)){ |
| 1381 | p->ntyp=clone_typ(ttyp); |
| 1382 | }else if(ttyp&&f==RSHIFT&&ttf<=INT&&ttf<=(p->left->ntyp->flags&NQ)&&shortcut(f,p->left->ntyp->flags&NU)){ |
| 1383 | p->ntyp=clone_typ(p->left->ntyp); |
| 1384 | }else{ |
| 1385 | p->ntyp=arith_typ(p->left->ntyp,p->left->ntyp); |
| 1386 | p->ntyp->flags&=~NQ; |
| 1387 | p->ntyp->flags|=int_erw(p->left->ntyp->flags); |
| 1388 | } |
| 1389 | if(p->right->flags==CEXPR){ |
| 1390 | eval_constn(p->right); |
| 1391 | if(!zmleq(l2zm(0L),vmax)) error(366); |
| 1392 | if(zmleq(zmmult(sizetab[p->ntyp->flags&NQ],char_bit),vmax)&&zmleq(zmmult(sizetab[p->left->ntyp->flags&NQ],char_bit),vmax)) error(367); |
| 1393 | } |
| 1394 | #ifdef HAVE_MISRA |
| 1395 | /* removed */ |
| 1396 | /* removed */ |
| 1397 | /* removed */ |
| 1398 | /* removed */ |
| 1399 | /* removed */ |
| 1400 | /* removed */ |
| 1401 | /* removed */ |
| 1402 | /* removed */ |
| 1403 | #endif |
| 1404 | }else{ |
| 1405 | /* ggfs. in kleinerem Zieltyp auswerten - bei float keinen shortcut (wäre evtl. double=>float unkritisch?) */ |
| 1406 | if(ttyp&&decide_shortcut(p,ttyp)) |
| 1407 | p->ntyp=clone_typ(ttyp); |
| 1408 | else |
| 1409 | p->ntyp=arith_typ(p->left->ntyp,p->right->ntyp); |
| 1410 | if(!ISINT(p->ntyp->flags)&&(f==MOD||f==LSHIFT||f==RSHIFT)) |
| 1411 | {error(101);ok=0;} |
| 1412 | } |
| 1413 | } |
| 1414 | /* fuegt &a+x zusammen, noch sub und left<->right machen */ |
| 1415 | /* Bei CEXPR statt PCEXPR auch machen? */ |
| 1416 | if((p->flags==ADD||p->flags==SUB)){ |
| 1417 | np m,c=0,a=0; |
| 1418 | if(p->left->flags==PCEXPR&&p->flags==ADD) c=p->left; |
| 1419 | if(p->right->flags==PCEXPR) c=p->right; |
| 1420 | if(p->left->flags==ADDRESS||p->left->flags==ADDRESSA||p->left->flags==ADDRESSS) a=p->left; |
| 1421 | if(p->right->flags==ADDRESS||p->right->flags==ADDRESSA||p->right->flags==ADDRESSS) a=p->right; |
| 1422 | if(c&&a){ |
| 1423 | m=a->left; |
| 1424 | /* kann man das hier so machen oder muss man da mehr testen ? */ |
| 1425 | while(m->flags==FIRSTELEMENT||m->flags==ADDRESS||m->flags==ADDRESSA||m->flags==ADDRESSS) m=m->left; |
| 1426 | if((m->flags==IDENTIFIER||m->flags==STRING)&&!is_vlength(m->ntyp)){ |
| 1427 | if(DEBUG&1) printf("&a+x with %s combined\n",ename[p->left->flags]); |
| 1428 | eval_const(&c->val,c->ntyp->flags); |
| 1429 | if(p->flags==ADD) |
| 1430 | m->val.vmax=zumadd(m->val.vmax,vmax); |
| 1431 | else |
| 1432 | m->val.vmax=zmsub(m->val.vmax,vmax); |
| 1433 | vmax=szof(m->ntyp); |
| 1434 | if(!zmeqto(vmax,l2zm(0L))&&zumleq(vmax,m->val.vmax)){ |
| 1435 | if(zumeqto(vmax,m->val.vmax)) |
| 1436 | error(79); |
| 1437 | else |
| 1438 | error(80); |
| 1439 | } |
| 1440 | vmax=l2zm(0L); |
| 1441 | if(!zmeqto(m->val.vmax,l2zm(0L))&&zumleq(m->val.vmax,vmax)) error(80); |
| 1442 | free_expression(c); |
| 1443 | if(p->ntyp) freetyp(p->ntyp); |
| 1444 | *p=*a; |
| 1445 | free(a); |
| 1446 | return type_expression2(p,0); |
| 1447 | } |
| 1448 | } |
| 1449 | } |
| 1450 | if(!mopt){ |
| 1451 | if(!alg_opt(p,ttyp)) ierror(0); |
| 1452 | } |
| 1453 | return ok; |
| 1454 | } |
| 1455 | if(f==CAST){ |
| 1456 | int from=(p->left->ntyp->flags),to=(p->ntyp->flags); |
| 1457 | #ifdef HAVE_MISRA |
| 1458 | /* removed */ |
| 1459 | #endif |
| 1460 | from&=NQ;to&=NQ; |
| 1461 | if(to==VOID) return ok; |
| 1462 | if(from==VOID) |
| 1463 | {error(102);return 0;} |
| 1464 | if((!ISARITH(to)||!ISARITH(from))&& |
| 1465 | (!ISPOINTER(to)||!ISPOINTER(from))){ |
| 1466 | if(ISPOINTER(to)){ |
| 1467 | if(ISINT(from)){ |
| 1468 | #ifdef HAVE_MISRA |
| 1469 | /* removed */ |
| 1470 | #endif |
| 1471 | if(!zmleq(sizetab[from],sizetab[to])){ |
| 1472 | error(103); |
| 1473 | } |
| 1474 | }else{ |
| 1475 | error(104);return 0; |
| 1476 | } |
| 1477 | }else{ |
| 1478 | if(!ISPOINTER(from)) |
| 1479 | {error(105);return 0;} |
| 1480 | if(ISINT(to)){ |
| 1481 | #ifdef HAVE_MISRA |
| 1482 | /* removed */ |
| 1483 | #endif |
| 1484 | if(!zmleq(sizetab[from],sizetab[to])){ |
| 1485 | error(106); |
| 1486 | } |
| 1487 | }else{ |
| 1488 | error(104);return 0; |
| 1489 | } |
| 1490 | } |
| 1491 | } |
| 1492 | if(ISINT(from)&&ISINT(to)&&!zmleq(sizetab[from],sizetab[to])&&p->left->flags!=CEXPR) error(166); |
| 1493 | if(ISPOINTER(to)&&ISPOINTER(from)&&!zmleq(falign(p->ntyp->next),falign(p->left->ntyp->next))) |
| 1494 | error(167); |
| 1495 | if(p->left->flags==CEXPR){ |
| 1496 | eval_constn(p->left); |
| 1497 | if(ISPOINTER(p->ntyp->flags)) |
| 1498 | if(!zumeqto(vumax,ul2zum(0UL))||!zmeqto(vmax,l2zm(0L))||!zldeqto(vldouble,d2zld(0.0))) |
| 1499 | error(81); |
| 1500 | insert_constn(p); |
| 1501 | p->flags=CEXPR; |
| 1502 | if(!p->left->sidefx){ |
| 1503 | if(!no_cast_free) |
| 1504 | free_expression(p->left); |
| 1505 | p->left=0; |
| 1506 | } |
| 1507 | } |
| 1508 | #ifdef HAVE_ECPP |
| 1509 | /* removed */ |
| 1510 | /* removed */ |
| 1511 | /* removed */ |
| 1512 | /* removed */ |
| 1513 | /* removed */ |
| 1514 | /* removed */ |
| 1515 | /* removed */ |
| 1516 | /* removed */ |
| 1517 | /* removed */ |
| 1518 | /* removed */ |
| 1519 | /* removed */ |
| 1520 | /* removed */ |
| 1521 | /* removed */ |
| 1522 | /* removed */ |
| 1523 | /* removed */ |
| 1524 | /* removed */ |
| 1525 | /* removed */ |
| 1526 | /* removed */ |
| 1527 | /* removed */ |
| 1528 | /* removed */ |
| 1529 | /* removed */ |
| 1530 | /* removed */ |
| 1531 | /* removed */ |
| 1532 | /* removed */ |
| 1533 | /* removed */ |
| 1534 | /* removed */ |
| 1535 | /* removed */ |
| 1536 | /* removed */ |
| 1537 | #endif |
| 1538 | return ok; |
| 1539 | } |
| 1540 | if(f==MINUS||f==KOMPLEMENT||f==NEGATION){ |
| 1541 | if(ISVECTOR(p->left->ntyp->flags)){ |
| 1542 | if(f==NEGATION){ |
| 1543 | if(ISFLOAT(VECTYPE(p->left->ntyp->flags))){error(98);return 0;} |
| 1544 | p->ntyp=new_typ(); |
| 1545 | p->ntyp->flags=p->left->ntyp->flags&NQ; |
| 1546 | return ok; |
| 1547 | } |
| 1548 | if(f==KOMPLEMENT&&ISFLOAT(VECTYPE(p->left->ntyp->flags))){error(109);return 0;} |
| 1549 | p->ntyp=clone_typ(p->left->ntyp); |
| 1550 | return ok; |
| 1551 | } |
| 1552 | if(!ISARITH(p->left->ntyp->flags)){ |
| 1553 | if(f!=NEGATION){ |
| 1554 | error(107);return 0; |
| 1555 | }else{ |
| 1556 | if(!ISPOINTER(p->left->ntyp->flags)) |
| 1557 | {error(108);return 0;} |
| 1558 | } |
| 1559 | } |
| 1560 | #ifdef HAVE_MISRA |
| 1561 | /* removed */ |
| 1562 | /* removed */ |
| 1563 | #endif |
| 1564 | if(f==KOMPLEMENT&&!ISINT(p->left->ntyp->flags)) |
| 1565 | {error(109);return 0;} |
| 1566 | if(f==NEGATION){ |
| 1567 | p->ntyp=new_typ(); |
| 1568 | p->ntyp->flags=INT; |
| 1569 | }else{ |
| 1570 | if(!p->left->ntyp) ierror(0); |
| 1571 | p->ntyp=clone_typ(p->left->ntyp); |
| 1572 | if(ISINT(p->ntyp->flags)){ |
| 1573 | if(!ttyp||!shortcut(f,ttyp->flags&NU)){ |
| 1574 | p->ntyp->flags=int_erw(p->ntyp->flags); |
| 1575 | }else{ |
| 1576 | if((f==MINUS&&!zmleq(sizetab[ttyp->flags&NQ],sizetab[p->ntyp->flags&NQ]))|| |
| 1577 | (f==KOMPLEMENT&&!zmleq(sizetab[ttyp->flags&NQ],sizetab[p->ntyp->flags&NQ])&&(p->ntyp->flags&UNSIGNED))) |
| 1578 | p->ntyp->flags=int_erw(p->ntyp->flags); |
| 1579 | } |
| 1580 | } |
| 1581 | } |
| 1582 | if(p->left->flags==CEXPR){ |
| 1583 | eval_constn(p->left); |
| 1584 | if(f==KOMPLEMENT){ |
| 1585 | if(p->ntyp->flags&UNSIGNED){ |
| 1586 | gval.vumax=zumkompl(vumax); |
| 1587 | eval_const(&gval,(UNSIGNED|MAXINT)); |
| 1588 | }else{ |
| 1589 | gval.vmax=zmkompl(vmax); |
| 1590 | eval_const(&gval,MAXINT); |
| 1591 | } |
| 1592 | } |
| 1593 | if(f==MINUS){ |
| 1594 | if(ISFLOAT(p->ntyp->flags)){ |
| 1595 | gval.vldouble=zldsub(d2zld(0.0),vldouble); |
| 1596 | eval_const(&gval,LDOUBLE); |
| 1597 | }else{ |
| 1598 | if(p->ntyp->flags&UNSIGNED){ |
| 1599 | gval.vumax=zumsub(ul2zum(0UL),vumax); |
| 1600 | eval_const(&gval,(UNSIGNED|MAXINT)); |
| 1601 | }else{ |
| 1602 | gval.vmax=zmsub(l2zm(0L),vmax); |
| 1603 | eval_const(&gval,MAXINT); |
| 1604 | } |
| 1605 | } |
| 1606 | } |
| 1607 | if(f==NEGATION){ |
| 1608 | if(zldeqto(vldouble,d2zld(0.0))&&zumeqto(vumax,ul2zum(0UL))&&zmeqto(vmax,l2zm(0L))) |
| 1609 | gval.vmax=l2zm(1L); |
| 1610 | else |
| 1611 | gval.vmax=l2zm(0L); |
| 1612 | eval_const(&gval,MAXINT); |
| 1613 | } |
| 1614 | insert_constn(p); |
| 1615 | p->flags=CEXPR; |
| 1616 | if(!p->left->sidefx&&p->left) {free_expression(p->left);p->left=0;} |
| 1617 | } |
| 1618 | return ok; |
| 1619 | } |
| 1620 | if(f==CONTENT){ |
| 1621 | if(!ISPOINTER(p->left->ntyp->flags)) |
| 1622 | {error(111);return 0;} |
| 1623 | if(!ISARRAY(p->left->ntyp->next->flags)&&type_uncomplete(p->left->ntyp->next)) |
| 1624 | {error(112);return 0;} |
| 1625 | p->ntyp=clone_typ(p->left->ntyp->next); |
| 1626 | if(!ISARRAY(p->ntyp->flags)) p->lvalue=1; |
| 1627 | if(p->left->flags==ADDRESS&&zumeqto(p->left->val.vumax,ul2zum(0UL))){ |
| 1628 | /* *&x durch x ersetzen */ |
| 1629 | np merk; |
| 1630 | merk=p->left; |
| 1631 | if(p->ntyp) freetyp(p->ntyp); |
| 1632 | if(p->left->ntyp) freetyp(p->left->ntyp); |
| 1633 | *p=*p->left->left; |
| 1634 | free(merk->left); |
| 1635 | free(merk); |
| 1636 | return ok; |
| 1637 | } |
| 1638 | /* *&ax durch firstelement-of(x) ersetzen */ |
| 1639 | if(p->left->flags==ADDRESSA||p->left->flags==ADDRESSS){ |
| 1640 | if(!is_vlength(p->left->left->ntyp)){ |
| 1641 | np merk; |
| 1642 | if(DEBUG&1) printf("substitutet * and %s with FIRSTELEMENT\n",ename[p->left->flags]); |
| 1643 | p->flags=FIRSTELEMENT; |
| 1644 | p->lvalue=1; /* evtl. hier erst Abfrage ? */ |
| 1645 | merk=p->left; |
| 1646 | p->left=merk->left; |
| 1647 | p->right=merk->right; |
| 1648 | if(merk->ntyp) freetyp(merk->ntyp); |
| 1649 | free(merk); |
| 1650 | } |
| 1651 | } |
| 1652 | if (p->ntyp->flags&VOLATILE) p->sidefx=1; |
| 1653 | return ok; |
| 1654 | } |
| 1655 | if(f==FIRSTELEMENT){ |
| 1656 | if(ISARRAY(p->left->ntyp->flags)){ |
| 1657 | p->ntyp=clone_typ(p->left->ntyp->next); |
| 1658 | }else{ |
| 1659 | int i,n=-1; |
| 1660 | for(i=0;i<p->left->ntyp->exact->count;i++) |
| 1661 | if(!strcmp((*p->left->ntyp->exact->sl)[i].identifier,p->right->identifier)) n=i; |
| 1662 | if(n<0) ierror(0); |
| 1663 | p->ntyp=clone_typ((*p->left->ntyp->exact->sl)[n].styp); |
| 1664 | } |
| 1665 | p->lvalue=1; /* hier noch genauer testen ? */ |
| 1666 | return ok; |
| 1667 | } |
| 1668 | if(f==ADDRESS){ |
| 1669 | if(!ISFUNC(p->left->ntyp->flags)&&!ISARRAY(p->left->ntyp->flags)){ |
| 1670 | if(!p->left->lvalue){error(115);return 0;} |
| 1671 | if(p->left->flags==IDENTIFIER){ |
| 1672 | Var *v; |
| 1673 | v=find_var(p->left->identifier,0); |
| 1674 | if(!v){error(116,p->left->identifier);return 0;} |
| 1675 | if(v->storage_class==REGISTER) |
| 1676 | {error(117);return 0;} |
| 1677 | } |
| 1678 | } |
| 1679 | p->ntyp=new_typ(); |
| 1680 | p->ntyp->flags=ptype(p->left); |
| 1681 | p->ntyp->next=clone_typ(p->left->ntyp); |
| 1682 | fix_addr_ptype(p); |
| 1683 | return ok; |
| 1684 | } |
| 1685 | if(f==ADDRESSA){ |
| 1686 | p->ntyp=clone_typ(p->left->ntyp); |
| 1687 | p->ntyp->flags=ptype(p->left); |
| 1688 | fix_addr_ptype(p); |
| 1689 | return ok; |
| 1690 | } |
| 1691 | if(f==ADDRESSS){ |
| 1692 | int i,n=-1; |
| 1693 | struct_list *sl=0; |
| 1694 | if(!ecpp){ |
| 1695 | for(i=0;i<p->left->ntyp->exact->count;i++) |
| 1696 | if(!strcmp((*p->left->ntyp->exact->sl)[i].identifier,p->right->identifier)) n=i; |
| 1697 | if(n<0) |
| 1698 | return 0; |
| 1699 | else |
| 1700 | sl=&(*p->left->ntyp->exact->sl)[n]; |
| 1701 | } |
| 1702 | #ifdef HAVE_ECPP |
| 1703 | /* removed */ |
| 1704 | /* removed */ |
| 1705 | /* removed */ |
| 1706 | /* removed */ |
| 1707 | /* removed */ |
| 1708 | /* removed */ |
| 1709 | /* removed */ |
| 1710 | /* removed */ |
| 1711 | /* removed */ |
| 1712 | /* removed */ |
| 1713 | /* removed */ |
| 1714 | /* removed */ |
| 1715 | /* removed */ |
| 1716 | /* removed */ |
| 1717 | /* removed */ |
| 1718 | /* removed */ |
| 1719 | /* removed */ |
| 1720 | /* removed */ |
| 1721 | /* removed */ |
| 1722 | /* removed */ |
| 1723 | /* removed */ |
| 1724 | /* removed */ |
| 1725 | /* removed */ |
| 1726 | /* removed */ |
| 1727 | /* removed */ |
| 1728 | /* removed */ |
| 1729 | /* removed */ |
| 1730 | /* removed */ |
| 1731 | /* removed */ |
| 1732 | /* removed */ |
| 1733 | /* removed */ |
| 1734 | /* removed */ |
| 1735 | #endif |
| 1736 | p->ntyp=new_typ(); |
| 1737 | if(!p->left->ntyp) ierror(0); |
| 1738 | if(!p->left->ntyp->exact) ierror(0); |
| 1739 | if(!sl->styp) ierror(0); |
| 1740 | p->ntyp->next=clone_typ(sl->styp); |
| 1741 | p->ntyp->flags=ptype(p->left); |
| 1742 | fix_addr_ptype(p); |
| 1743 | return ok; |
| 1744 | } |
| 1745 | if(f==DSTRUCT){ |
| 1746 | struct_declaration *sd=p->left->ntyp->exact; |
| 1747 | char *identifier=p->right->identifier; |
| 1748 | int i=0,f,bfs=-1,bfo=-1;type *t;np new;zmax offset=l2zm(0L); |
| 1749 | if(!ISSTRUCT(p->left->ntyp->flags)&&!ISUNION(p->left->ntyp->flags)) |
| 1750 | {error(8);return 0;} |
| 1751 | if(type_uncomplete(p->left->ntyp)){error(11);return 0;} |
| 1752 | if(p->right->flags!=MEMBER) ierror(0); |
| 1753 | if(i>=p->left->ntyp->exact->count) {error(23,p->right->identifier);return 0;} |
| 1754 | if(!ecpp){ |
| 1755 | offset=struct_offset(sd,identifier); |
| 1756 | } |
| 1757 | #ifdef HAVE_ECPP |
| 1758 | /* removed */ |
| 1759 | /* removed */ |
| 1760 | /* removed */ |
| 1761 | /* removed */ |
| 1762 | /* removed */ |
| 1763 | /* removed */ |
| 1764 | /* removed */ |
| 1765 | /* removed */ |
| 1766 | /* removed */ |
| 1767 | /* removed */ |
| 1768 | /* removed */ |
| 1769 | /* removed */ |
| 1770 | /* removed */ |
| 1771 | /* removed */ |
| 1772 | /* removed */ |
| 1773 | /* removed */ |
| 1774 | /* removed */ |
| 1775 | /* removed */ |
| 1776 | /* removed */ |
| 1777 | /* removed */ |
| 1778 | /* removed */ |
| 1779 | /* removed */ |
| 1780 | /* removed */ |
| 1781 | /* removed */ |
| 1782 | /* removed */ |
| 1783 | /* removed */ |
| 1784 | /* removed */ |
| 1785 | /* removed */ |
| 1786 | /* removed */ |
| 1787 | /* removed */ |
| 1788 | /* removed */ |
| 1789 | /* removed */ |
| 1790 | /* removed */ |
| 1791 | /* removed */ |
| 1792 | /* removed */ |
| 1793 | /* removed */ |
| 1794 | /* removed */ |
| 1795 | /* removed */ |
| 1796 | /* removed */ |
| 1797 | /* removed */ |
| 1798 | /* removed */ |
| 1799 | /* removed */ |
| 1800 | /* removed */ |
| 1801 | /* removed */ |
| 1802 | /* removed */ |
| 1803 | /* removed */ |
| 1804 | /* removed */ |
| 1805 | /* removed */ |
| 1806 | /* removed */ |
| 1807 | #endif |
| 1808 | if(ISUNION(p->left->ntyp->flags)) offset=l2zm(0L); |
| 1809 | p->flags=CONTENT; |
| 1810 | if(p->ntyp) {freetyp(p->ntyp);p->ntyp=0;} |
| 1811 | new=new_node(); |
| 1812 | new->flags=ADD; |
| 1813 | new->ntyp=0; |
| 1814 | new->right=new_node(); |
| 1815 | new->right->left=new->right->right=0; |
| 1816 | new->right->flags=PCEXPR; |
| 1817 | new->right->ntyp=new_typ(); |
| 1818 | if(/*MINADDI2P<=INT&&*/zumleq(zm2zum(offset),t_max(INT))){ |
| 1819 | new->right->ntyp->flags=INT; |
| 1820 | new->right->val.vint=zm2zi(offset); |
| 1821 | }else{ |
| 1822 | new->right->ntyp->flags=LONG; |
| 1823 | new->right->ntyp->next=0; |
| 1824 | new->right->val.vlong=zm2zl(offset); |
| 1825 | } |
| 1826 | new->left=new_node(); |
| 1827 | new->left->flags=ADDRESSS; |
| 1828 | new->left->left=p->left; |
| 1829 | new->left->right=p->right; |
| 1830 | new->left->ntyp=0; |
| 1831 | p->left=new;p->right=0; |
| 1832 | |
| 1833 | /* Check for bitfields */ |
| 1834 | i=0; |
| 1835 | while(i<sd->count&&strcmp((*sd->sl)[i].identifier,identifier)){ |
| 1836 | i++; |
| 1837 | } |
| 1838 | if(i<sd->count){ |
| 1839 | bfo=(*sd->sl)[i].bfoffset; |
| 1840 | bfs=(*sd->sl)[i].bfsize; |
| 1841 | }else |
| 1842 | bfs=-1; |
| 1843 | if(bfs!=-1){ |
| 1844 | /* create a special node for bitfields */ |
| 1845 | ok|=type_expression2(p,0); |
| 1846 | new=new_node(); |
| 1847 | *new=*p; |
| 1848 | p->flags=BITFIELD; |
| 1849 | p->left=new; |
| 1850 | p->right=0; |
| 1851 | p->sidefx=0; |
| 1852 | p->bfs=bfs; |
| 1853 | p->bfo=bfo; |
| 1854 | p->ntyp=clone_typ(new->ntyp); |
| 1855 | return ok; |
| 1856 | } |
| 1857 | return type_expression2(p,0); |
| 1858 | } |
| 1859 | if(f==PREINC||f==POSTINC||f==PREDEC||f==POSTDEC){ |
| 1860 | if(!p->left->lvalue){error(86);return 0;} |
| 1861 | if(p->left->ntyp->flags&CONST){error(87);return 0;} |
| 1862 | if(!ISARITH(p->left->ntyp->flags)){ |
| 1863 | if(!ISPOINTER(p->left->ntyp->flags)){ |
| 1864 | error(24); |
| 1865 | return 0; |
| 1866 | }else{ |
| 1867 | #ifdef HAVE_MISRA |
| 1868 | /* removed */ |
| 1869 | #endif |
| 1870 | if((p->left->ntyp->next->flags&NQ)==VOID) |
| 1871 | {error(95);return 0;} |
| 1872 | } |
| 1873 | } |
| 1874 | p->ntyp=clone_typ(p->left->ntyp); |
| 1875 | p->sidefx=1; |
| 1876 | return ok; |
| 1877 | } |
| 1878 | if(f==CALL){ |
| 1879 | argument_list *al;int i,flags=0;char *s=0; |
| 1880 | struct_declaration *sd; |
| 1881 | #ifdef HAVE_ECPP |
| 1882 | /* removed */ |
| 1883 | /* removed */ |
| 1884 | /* removed */ |
| 1885 | /* removed */ |
| 1886 | /* removed */ |
| 1887 | /* removed */ |
| 1888 | /* removed */ |
| 1889 | #endif |
| 1890 | al=p->alist; |
| 1891 | if(!ISPOINTER(p->left->ntyp->flags)||!ISFUNC(p->left->ntyp->next->flags)) |
| 1892 | {error(26);return 0;} |
| 1893 | if(ok&&p->left->left&&p->left->left->flags==IDENTIFIER&&p->left->left->o.v->storage_class==EXTERN){ |
| 1894 | s=p->left->left->o.v->identifier; |
| 1895 | flags=p->left->left->o.v->flags; |
| 1896 | } |
| 1897 | sd=p->left->ntyp->next->exact; |
| 1898 | if(!sd) ierror(0); |
| 1899 | if(sd->count==0){ |
| 1900 | #ifdef HAVE_MISRA |
| 1901 | /* removed */ |
| 1902 | #endif |
| 1903 | error(162); |
| 1904 | if(s){ |
| 1905 | if(!strcmp(s,"printf")||!strcmp(s,"fprintf")||!strcmp(s,"sprintf")|| |
| 1906 | !strcmp(s,"scanf")|| !strcmp(s,"fscanf")|| !strcmp(s,"sscanf")) |
| 1907 | error(213); |
| 1908 | } |
| 1909 | } |
| 1910 | if(!(ecpp&&al&&al->arg->ntyp)){ |
| 1911 | i=0; |
| 1912 | while(al){ |
| 1913 | if(!al->arg) ierror(0); |
| 1914 | if(!type_expression2(al->arg,(short_push&&i<sd->count)?(*sd->sl)[i].styp:0)) return 0; |
| 1915 | al->arg=makepointer(al->arg); |
| 1916 | if(type_uncomplete(al->arg->ntyp)) error(39); |
| 1917 | al=al->next; |
| 1918 | i++; |
| 1919 | } |
| 1920 | } |
| 1921 | p->sidefx=1; |
| 1922 | p->ntyp=clone_typ(p->left->ntyp->next->next); |
| 1923 | i=0;al=p->alist; |
| 1924 | while(al){ |
| 1925 | if(i>=sd->count) return ok; |
| 1926 | if(!(*sd->sl)[i].styp) return ok; /* nur Bezeichner, aber kein Typ im Prototype */ |
| 1927 | if(!test_assignment((*sd->sl)[i].styp,al->arg)) return 0; |
| 1928 | #ifdef HAVE_MISRA |
| 1929 | /* removed */ |
| 1930 | /* removed */ |
| 1931 | #endif |
| 1932 | if(i==sd->count-1&&(flags&(PRINTFLIKE|SCANFLIKE))){ |
| 1933 | if(al->arg->left&&al->arg->left->flags==STRING){ |
| 1934 | /* Argumente anhand des Formatstrings ueberpruefen */ |
| 1935 | const_list *cl=al->arg->left->cl; |
| 1936 | int fused=0;long mask=1; |
| 1937 | al=al->next; |
| 1938 | while(cl&&cl->other){ |
| 1939 | int c,fflags=' ',at,lflag; |
| 1940 | type *t; |
| 1941 | enum{LL=1,HH}; |
| 1942 | c=(int)zm2l(zc2zm(cl->other->val.vchar)); |
| 1943 | cl=cl->next; |
| 1944 | if(c==0){ |
| 1945 | if(cl) error(215); |
| 1946 | break; |
| 1947 | } |
| 1948 | c=CHARBACK(c); |
| 1949 | if(c!='%') continue; |
| 1950 | if(!cl){error(214);return ok;} |
| 1951 | lflag=0; |
| 1952 | c=(int)zm2l(zc2zm(cl->other->val.vchar)); |
| 1953 | c=CHARBACK(c); |
| 1954 | cl=cl->next; |
| 1955 | while(isdigit((unsigned char)c)|| |
| 1956 | c=='-'||c=='+'||c==' '||c=='#'||c=='.'|| |
| 1957 | c=='h'||c=='l'||c=='L'||c=='z'||c=='j'||c=='t'||c=='*'){ |
| 1958 | if(c=='-') mask|=USELALGN; |
| 1959 | if(c=='+') mask|=USESIGN; |
| 1960 | if(c=='#') mask|=USEALT; |
| 1961 | if(c=='.') mask|=USEPREC; |
| 1962 | if(c==' ') mask|=USEBLANK; |
| 1963 | if(c=='0'&&!(mask&USEPREC)&&!(mask&USEWIDTH)) mask|=USEZPAD; |
| 1964 | if(isdigit((unsigned char)c)&&!(mask&USEPREC)) mask|=USEWIDTH; |
| 1965 | fused|=3; |
| 1966 | if(c=='*'&&(flags&PRINTFLIKE)){ |
| 1967 | mask|=USEAST; |
| 1968 | if(!al) {error(214);return ok;} |
| 1969 | at=al->arg->ntyp->flags&NQ; |
| 1970 | al=al->next; |
| 1971 | if(at>INT) {error(214);return ok;} |
| 1972 | } |
| 1973 | if((fflags!='*'||(flags&PRINTFLIKE))&&(c=='h'||c=='l'||c=='L'||c=='*'||c=='t'||c=='z'||c=='j')){ |
| 1974 | if(c=='l'&&fflags=='l') |
| 1975 | fflags=LL; |
| 1976 | else if(c=='h'&&fflags=='h') |
| 1977 | fflags=HH; |
| 1978 | else |
| 1979 | fflags=c; |
| 1980 | } |
| 1981 | c=(int)zm2l(zc2zm(cl->other->val.vchar)); |
| 1982 | c=CHARBACK(c); |
| 1983 | cl=cl->next; |
| 1984 | if(!cl){error(214);return ok;} |
| 1985 | } |
| 1986 | /*FIXME: assumes intmax_t==long long */ |
| 1987 | if(fflags=='j') {mask|=USESPEC;fflags=LL;} |
| 1988 | #if HAVE_INT_SIZET |
| 1989 | if(fflags=='z') {mask|=USESPEC;fflags=' ';} |
| 1990 | #else |
| 1991 | if(fflags=='z') {mask|=USESPEC;fflags='l';} |
| 1992 | #endif |
| 1993 | if(fflags=='t'){ |
| 1994 | mask|=USESPEC; |
| 1995 | if(PTRDIFF_T(CHAR)==LLONG) |
| 1996 | fflags=LL; |
| 1997 | else if(PTRDIFF_T(CHAR)==LONG) |
| 1998 | fflags='l'; |
| 1999 | else |
| 2000 | fflags=' '; |
| 2001 | } |
| 2002 | if(fflags==HH) lflag|=USESPEC; |
| 2003 | if(fflags=='h') lflag|=USEHALF; |
| 2004 | if(fflags=='l') lflag|=USELONG; |
| 2005 | if(fflags==LL) lflag|=USELLONG; |
| 2006 | if(DEBUG&1) printf("format=%c%c\n",fflags,c); |
| 2007 | if(fflags=='*'&&(flags&SCANFLIKE)) continue; |
| 2008 | if(c!='%'){ |
| 2009 | if(!al){error(214);return ok;} |
| 2010 | t=al->arg->ntyp; |
| 2011 | if(DEBUG&1){ prd(stdout,t);printf("\n");} |
| 2012 | if((flags&SCANFLIKE)){ |
| 2013 | if(!ISPOINTER(t->flags)){error(214);return ok;} |
| 2014 | t=t->next; |
| 2015 | } |
| 2016 | at=t->flags&NU; |
| 2017 | } |
| 2018 | if(flags&PRINTFLIKE){ |
| 2019 | switch(c){ |
| 2020 | case '%': |
| 2021 | mask|=USEPERC; |
| 2022 | fused|=1; |
| 2023 | break; |
| 2024 | case 'o': |
| 2025 | case 'x': |
| 2026 | case 'X': |
| 2027 | case 'c': |
| 2028 | at&=NQ; /* fall through */ |
| 2029 | case 'i': |
| 2030 | case 'd': |
| 2031 | fused|=1; |
| 2032 | if(at==LLONG&&fflags!=LL){error(214);return ok;} |
| 2033 | if(at==LONG&&fflags!='l'){error(214);return ok;} |
| 2034 | if(fflags=='l'&&at!=LONG){error(214);return ok;} |
| 2035 | if(at<CHAR||at>LLONG){error(214);return ok;} |
| 2036 | if(c=='o') mask|=USEOCT; |
| 2037 | if(c=='x') mask|=USEHEXL; |
| 2038 | if(c=='X') mask|=USEHEXU; |
| 2039 | if(c=='i') mask|=USEINT; |
| 2040 | if(c=='d') mask|=USEDEC; |
| 2041 | if(c=='c') mask|=USECHAR; |
| 2042 | mask|=lflag; |
| 2043 | break; |
| 2044 | case 'u': |
| 2045 | mask|=USEUNS; |
| 2046 | fused|=1; |
| 2047 | if(al->arg->flags==CEXPR) at|=UNSIGNED; |
| 2048 | if(at==(UNSIGNED|LLONG)&&fflags!=LL){error(214);return ok;} |
| 2049 | if(at==(UNSIGNED|LONG)&&fflags!='l'){error(214);return ok;} |
| 2050 | if(fflags=='l'&&at!=(UNSIGNED|LONG)){error(214);return ok;} |
| 2051 | if(at<(UNSIGNED|CHAR)||at>(UNSIGNED|LLONG)){error(214);return ok;} |
| 2052 | mask|=lflag; |
| 2053 | break; |
| 2054 | case 's': |
| 2055 | mask|=USESTR; |
| 2056 | fused|=1; |
| 2057 | if(!ISPOINTER(at)||(t->next->flags&NQ)!=CHAR){error(214);return ok;} |
| 2058 | break; |
| 2059 | case 'f': |
| 2060 | case 'e': |
| 2061 | case 'E': |
| 2062 | case 'g': |
| 2063 | case 'G': |
| 2064 | mask|=USEFLOAT; |
| 2065 | fused|=7; |
| 2066 | if(fflags=='L'){ |
| 2067 | if(at!=LDOUBLE){error(214); return ok;} |
| 2068 | }else{ |
| 2069 | if(at!=FLOAT&&at!=DOUBLE){error(214);return ok;} |
| 2070 | } |
| 2071 | break; |
| 2072 | case 'p': |
| 2073 | mask|=USESPEC; |
| 2074 | fused|=3; |
| 2075 | if(!ISPOINTER(at)||(t->next->flags)!=VOID){error(214);return ok;} |
| 2076 | break; |
| 2077 | case 'n': |
| 2078 | mask|=USECNT; |
| 2079 | fused|=3; |
| 2080 | if(!ISPOINTER(at)){error(214);return ok;} |
| 2081 | at=t->next->flags&NU; |
| 2082 | if(fflags==HH&&at!=CHAR){error(214);return ok;} |
| 2083 | if(fflags=='h'&&at!=SHORT){error(214);return ok;} |
| 2084 | if(fflags==' '&&at!=INT){error(214);return ok;} |
| 2085 | if(fflags=='l'&&at!=LONG){error(214);return ok;} |
| 2086 | if(fflags==LL&&at!=LLONG){error(214);return ok;} |
| 2087 | break; |
| 2088 | default: |
| 2089 | error(214);return ok; |
| 2090 | } |
| 2091 | }else{ |
| 2092 | if(c=='s') mask|=USESTR; |
| 2093 | if(c=='c') mask|=USECHAR; |
| 2094 | if(c=='n') mask|=USECNT; |
| 2095 | if(c=='d') mask|=USEDEC; |
| 2096 | if(c=='i') mask|=USEINT; |
| 2097 | if(c=='o') mask|=USEOCT; |
| 2098 | if(c=='x') mask|=USEHEXL; |
| 2099 | if(c=='u') mask|=USEUNS; |
| 2100 | |
| 2101 | switch(c){ |
| 2102 | case '%': |
| 2103 | mask|=USEPERC; |
| 2104 | fused|=1; |
| 2105 | break; |
| 2106 | case '[': |
| 2107 | mask|=USEREXP; |
| 2108 | fused|=3; |
| 2109 | do{ |
| 2110 | c=(int)zm2l(zc2zm(cl->other->val.vchar)); |
| 2111 | c=CHARBACK(c); |
| 2112 | cl=cl->next; |
| 2113 | if(!cl){error(214);return ok;} |
| 2114 | }while(c!=']'); /* fall through */ |
| 2115 | case 's': |
| 2116 | case 'c': |
| 2117 | fused|=1; |
| 2118 | if((at&NQ)!=CHAR){error(214);return(ok);} |
| 2119 | break; |
| 2120 | case 'n': |
| 2121 | fused|=3; /* fall through */ |
| 2122 | case 'd': |
| 2123 | case 'i': |
| 2124 | case 'o': |
| 2125 | fused|=1; |
| 2126 | if(fflags==HH&&at!=CHAR){error(214);return ok;} |
| 2127 | if(fflags=='h'&&at!=SHORT){error(214);return ok;} |
| 2128 | if(fflags==' '&&at!=INT){error(214);return ok;} |
| 2129 | if(fflags=='l'&&at!=LONG){error(214);return ok;} |
| 2130 | if(fflags==LL&&at!=LLONG){error(214);return ok;} |
| 2131 | break; |
| 2132 | case 'x': |
| 2133 | case 'u': |
| 2134 | fused|=1; |
| 2135 | if(fflags==HH&&at!=CHAR){error(214);return ok;} |
| 2136 | if(fflags=='h'&&at!=(UNSIGNED|SHORT)){error(214);return ok;} |
| 2137 | if(fflags==' '&&at!=(UNSIGNED|INT)){error(214);return ok;} |
| 2138 | if(fflags=='l'&&at!=(UNSIGNED|LONG)){error(214);return ok;} |
| 2139 | if(fflags==LL&&at!=(UNSIGNED|LLONG)){error(214);return ok;} |
| 2140 | break; |
| 2141 | case 'e': |
| 2142 | case 'f': |
| 2143 | case 'g': |
| 2144 | mask|=USEFLOAT; |
| 2145 | fused|=7; |
| 2146 | if(fflags==' '&&at!=FLOAT){error(214);return ok;} |
| 2147 | if(fflags=='l'&&at!=DOUBLE){error(214);return ok;} |
| 2148 | if(fflags=='L'&&at!=LDOUBLE){error(214);return ok;} |
| 2149 | break; |
| 2150 | case 'p': |
| 2151 | mask|=USESPEC; |
| 2152 | fused|=3; |
| 2153 | if(!ISPOINTER(at)||(t->next->flags&NQ)!=VOID){error(214);return ok;} |
| 2154 | break; |
| 2155 | default: |
| 2156 | error(214);return ok; |
| 2157 | } |
| 2158 | } |
| 2159 | if(c!='%') al=al->next; |
| 2160 | } |
| 2161 | if(al){ error(214);return ok;} /* zu viele */ |
| 2162 | if(DEBUG&1) printf("fused=%d\n",fused); |
| 2163 | if(mask_opt){ |
| 2164 | Var *v;char repl[MAXI+16]; |
| 2165 | if(mask){ |
| 2166 | sprintf(repl,"%s.%lu",s,1L); |
| 2167 | v=find_var(repl,0); |
| 2168 | if(!v){ |
| 2169 | type *t; |
| 2170 | v=find_var(s,0); |
| 2171 | if(!v) ierror(0); |
| 2172 | v=add_var(repl,clone_typ(v->vtyp),EXTERN,0); |
| 2173 | } |
| 2174 | } |
| 2175 | if(mask) |
| 2176 | sprintf(repl,"%s.%lu",(flags&PRINTFLIKE)?"vfprintf":"vfscanf",mask); |
| 2177 | else |
| 2178 | sprintf(repl,"%s",(flags&PRINTFLIKE)?"vfprintf":"vfscanf"); |
| 2179 | needs(repl); |
| 2180 | p->left->left->o.v=v; |
| 2181 | if(DEBUG&1) printf("repl=%s\n",repl); |
| 2182 | }else if(fused!=7&&s){ |
| 2183 | /* Wenn kein Format benutzt wird, kann man printf, */ |
| 2184 | /* scanf etc. durch aehnliches ersetzen. */ |
| 2185 | Var *v;char repl[MAXI+6]="__v"; |
| 2186 | if(fused==3) fused=2; |
| 2187 | repl[3]=fused+'0';repl[4]=0; |
| 2188 | strcat(repl,s); |
| 2189 | if(DEBUG&1) printf("repl=%s\n",repl); |
| 2190 | while(fused<=2){ |
| 2191 | v=find_var(repl,0); |
| 2192 | if(v&&v->storage_class==EXTERN){ |
| 2193 | p->left->left->o.v=v; |
| 2194 | break; |
| 2195 | } |
| 2196 | fused++;repl[3]++; |
| 2197 | } |
| 2198 | } |
| 2199 | return ok; |
| 2200 | } |
| 2201 | } |
| 2202 | i++;al=al->next; |
| 2203 | } |
| 2204 | if(i>=sd->count) return ok; |
| 2205 | if((*sd->sl)[i].styp&&((*sd->sl)[i].styp->flags&NQ)!=VOID){error(83);/*printf("sd->count=%d\n",sd->count);*/} |
| 2206 | return ok; |
| 2207 | } |
| 2208 | if(f==COND){ |
| 2209 | if(!ISARITH(p->left->ntyp->flags)&&!ISPOINTER(p->left->ntyp->flags)){ |
| 2210 | error(29); |
| 2211 | return 0; |
| 2212 | } |
| 2213 | if(p->left->flags==CEXPR&&!p->left->sidefx){ |
| 2214 | int null;np merk; |
| 2215 | if(DEBUG&1) printf("constant conditional-expression simplified\n"); |
| 2216 | eval_constn(p->left); |
| 2217 | if(zmeqto(vmax,l2zm(0L))&&zumeqto(vumax,ul2zum(0UL))&&zldeqto(vldouble,d2zld(0.0))) |
| 2218 | null=1; |
| 2219 | else |
| 2220 | null=0; |
| 2221 | free_expression(p->left); |
| 2222 | merk=p->right; |
| 2223 | if(null){ |
| 2224 | free_expression(p->right->left); |
| 2225 | *p=*p->right->right; |
| 2226 | }else{ |
| 2227 | free_expression(p->right->right); |
| 2228 | *p=*p->right->left; |
| 2229 | } |
| 2230 | if(merk->ntyp) freetyp(merk->ntyp); |
| 2231 | free(merk); |
| 2232 | return 1; |
| 2233 | } |
| 2234 | if(const_expr){error(46);return 0;} |
| 2235 | p->ntyp=clone_typ(p->right->ntyp); |
| 2236 | return 1; |
| 2237 | } |
| 2238 | if(f==COLON){ |
| 2239 | /* Hier fehlt noch korrekte Behandlung der Typattribute */ |
| 2240 | if(ISARITH(p->left->ntyp->flags)&&ISARITH(p->right->ntyp->flags)){ |
| 2241 | p->ntyp=arith_typ(p->left->ntyp,p->right->ntyp); |
| 2242 | return 1; |
| 2243 | } |
| 2244 | if(compatible_types(p->left->ntyp,p->right->ntyp,NQ)){ |
| 2245 | p->ntyp=clone_typ(p->left->ntyp); |
| 2246 | return 1; |
| 2247 | } |
| 2248 | if(ISPOINTER(p->left->ntyp->flags)&&ISPOINTER(p->right->ntyp->flags)){ |
| 2249 | if((p->left->ntyp->next->flags&NQ)==VOID){ |
| 2250 | if(nullpointer(p->left)) |
| 2251 | p->ntyp=clone_typ(p->right->ntyp); |
| 2252 | else |
| 2253 | p->ntyp=clone_typ(p->left->ntyp); |
| 2254 | return 1; |
| 2255 | } |
| 2256 | if((p->right->ntyp->next->flags&NQ)==VOID){ |
| 2257 | if(nullpointer(p->right)) |
| 2258 | p->ntyp=clone_typ(p->left->ntyp); |
| 2259 | else |
| 2260 | p->ntyp=clone_typ(p->right->ntyp); |
| 2261 | return 1; |
| 2262 | } |
| 2263 | } |
| 2264 | if(ISPOINTER(p->left->ntyp->flags)&&p->right->flags==CEXPR){ |
| 2265 | eval_constn(p->right); |
| 2266 | if(zmeqto(vmax,l2zm(0L))&&zumeqto(ul2zum(0UL),vumax)&&zldeqto(d2zld(0.0),vldouble)){ |
| 2267 | p->ntyp=clone_typ(p->left->ntyp); |
| 2268 | return 1; |
| 2269 | } |
| 2270 | } |
| 2271 | if(ISPOINTER(p->right->ntyp->flags)&&p->left->flags==CEXPR){ |
| 2272 | eval_constn(p->left); |
| 2273 | if(zmeqto(l2zm(0L),vmax)&&zumeqto(ul2zum(0UL),vumax)&&zldeqto(d2zld(0.0),vldouble)){ |
| 2274 | p->ntyp=clone_typ(p->right->ntyp); |
| 2275 | return 1; |
| 2276 | } |
| 2277 | } |
| 2278 | error(31); |
| 2279 | return 0; |
| 2280 | } |
| 2281 | if(f) printf("type_testing fuer diesen Operator (%d) noch nicht implementiert\n",f); |
| 2282 | return 0; |
| 2283 | } |
| 2284 | |
| 2285 | np makepointer(np p) |
| 2286 | /* Fuehrt automatische Zeigererzeugung fuer Baumwurzel durch */ |
| 2287 | /* Durch mehrmaligen Aufruf von type_expression() ineffizient */ |
| 2288 | { |
| 2289 | struct_declaration *sd; |
| 2290 | if(ISARRAY(p->ntyp->flags)||ISFUNC(p->ntyp->flags)){ |
| 2291 | np new=new_node(); |
| 2292 | if(ISARRAY(p->ntyp->flags)){ |
| 2293 | new->flags=ADDRESSA; |
| 2294 | new->ntyp=clone_typ(p->ntyp); |
| 2295 | new->ntyp->flags=POINTER_TYPE(new->ntyp->next); |
| 2296 | }else{ |
| 2297 | new->flags=ADDRESS; |
| 2298 | new->ntyp=new_typ(); |
| 2299 | new->ntyp->flags=POINTER_TYPE(p->ntyp); |
| 2300 | new->ntyp->next=clone_typ(p->ntyp); |
| 2301 | } |
| 2302 | new->left=p; |
| 2303 | new->right=0; |
| 2304 | new->lvalue=0; /* immer korrekt ? */ |
| 2305 | new->sidefx=p->sidefx; |
| 2306 | /* type_expression(new);*/ |
| 2307 | return new; |
| 2308 | }else |
| 2309 | return p; |
| 2310 | } |
| 2311 | |
| 2312 | void simple_alg_opt(np p) |
| 2313 | { |
| 2314 | int c=0,f,t=0; |
| 2315 | zldouble d1,d2; |
| 2316 | zumax u1,u2;zmax s1,s2; |
| 2317 | Var *v; |
| 2318 | |
| 2319 | if(!p) return; |
| 2320 | |
| 2321 | f=p->flags; |
| 2322 | |
| 2323 | if(f==IDENTIFIER&&(v=find_var(p->identifier,0))&&(v->vtyp->flags&NQ)==ENUM){ |
| 2324 | /* enumerations auch als Konstante (int) behandeln */ |
| 2325 | p->flags=CEXPR; |
| 2326 | if(!v->clist) ierror(0); |
| 2327 | p->val=v->clist->val; |
| 2328 | if(!p->ntyp) p->ntyp=new_typ(); |
| 2329 | p->ntyp->flags=CONST|INT; |
| 2330 | return; |
| 2331 | } |
| 2332 | |
| 2333 | |
| 2334 | if(p->left) |
| 2335 | simple_alg_opt(p->left); |
| 2336 | else |
| 2337 | return; |
| 2338 | if(p->right) |
| 2339 | simple_alg_opt(p->right); |
| 2340 | |
| 2341 | if(p->left->flags==CEXPR||p->left->flags==PCEXPR){ |
| 2342 | eval_constn(p->left); |
| 2343 | d1=vldouble;u1=vumax;s1=vmax;c|=1; |
| 2344 | } |
| 2345 | if(p->right&&(p->right->flags==CEXPR||p->right->flags==PCEXPR)){ |
| 2346 | eval_constn(p->right); |
| 2347 | d2=vldouble;u2=vumax;s2=vmax;c|=2; |
| 2348 | } |
| 2349 | |
| 2350 | if(p->ntyp) t=p->ntyp->flags; |
| 2351 | |
| 2352 | if(c==3&&((f>=OR&&f<=AND)||(f>=LSHIFT&&f<=MOD))){ |
| 2353 | if(DEBUG&1) printf("did simple_alg constant folding\n"); |
| 2354 | if(!t) t=arith_flag(p->left->ntyp->flags,p->right->ntyp->flags); |
| 2355 | if(DEBUG&1) printf("did simple constant folding\n"); |
| 2356 | |
| 2357 | if(f==AND&&ISINT(t)){ |
| 2358 | vumax=zumand(u1,u2); |
| 2359 | vmax=zmand(s1,s2); |
| 2360 | } |
| 2361 | if(f==OR&&ISINT(t)){ |
| 2362 | vumax=zumor(u1,u2); |
| 2363 | vmax=zmor(s1,s2); |
| 2364 | } |
| 2365 | if(f==XOR&&ISINT(t)){ |
| 2366 | vumax=zumxor(u1,u2); |
| 2367 | vmax=zmxor(s1,s2); |
| 2368 | } |
| 2369 | if(f==ADD){ |
| 2370 | vumax=zumadd(u1,u2); |
| 2371 | vmax=zmadd(s1,s2); |
| 2372 | vldouble=zldadd(d1,d2); |
| 2373 | } |
| 2374 | if(f==SUB){ |
| 2375 | vumax=zumsub(u1,u2); |
| 2376 | vmax=zmsub(s1,s2); |
| 2377 | vldouble=zldsub(d1,d2); |
| 2378 | } |
| 2379 | if(f==MULT||f==PMULT){ |
| 2380 | vumax=zummult(u1,u2); |
| 2381 | vmax=zmmult(s1,s2); |
| 2382 | vldouble=zldmult(d1,d2); |
| 2383 | if(f==PMULT) p->flags=PCEXPR; |
| 2384 | } |
| 2385 | if(f==DIV){ |
| 2386 | if(zmeqto(l2zm(0L),s2)&&zumeqto(ul2zum(0UL),u2)&&zldeqto(d2zld(0.0),d2)){ |
| 2387 | error(84); |
| 2388 | vmax=l2zm(0L);vumax=ul2zum(0UL);vldouble=d2zld(0.0); |
| 2389 | }else{ |
| 2390 | if(!zumeqto(ul2zum(0UL),u2)) vumax=zumdiv(u1,u2); |
| 2391 | if(!zmeqto(l2zm(0L),s2)) vmax=zmdiv(s1,s2); |
| 2392 | if(!zldeqto(d2zld(0.0),d2)) vldouble=zlddiv(d1,d2); |
| 2393 | } |
| 2394 | } |
| 2395 | if(f==MOD&&ISINT(t)){ |
| 2396 | if(zmeqto(l2zm(0L),s2)&&zumeqto(ul2zum(0UL),u2)){ |
| 2397 | error(84); |
| 2398 | vmax=l2zm(0L);vumax=zm2zum(vmax); |
| 2399 | }else{ |
| 2400 | if(!zumeqto(ul2zum(0UL),u2)) vumax=zummod(u1,u2); |
| 2401 | if(!zmeqto(l2zm(0L),s2)) vmax=zmmod(s1,s2); |
| 2402 | } |
| 2403 | } |
| 2404 | if(f==LSHIFT&&ISINT(t)){ |
| 2405 | vumax=zumlshift(u1,u2); |
| 2406 | vmax=zmlshift(s1,s2); |
| 2407 | } |
| 2408 | if(f==RSHIFT&&ISINT(t)){ |
| 2409 | vumax=zumrshift(u1,u2); |
| 2410 | vmax=zmrshift(s1,s2); |
| 2411 | } |
| 2412 | }else if(c==1&&f==MINUS){ |
| 2413 | if(!t) t=arith_flag(p->left->ntyp->flags,p->left->ntyp->flags); |
| 2414 | vmax=zmsub(Z0,s1); |
| 2415 | vumax=zumsub(ZU0,u1); |
| 2416 | vldouble=zldsub(d2zld(0.0),d1); |
| 2417 | }else if(c==1&&f==KOMPLEMENT){ |
| 2418 | if(!t) t=arith_flag(p->left->ntyp->flags,p->left->ntyp->flags); |
| 2419 | if(!ISINT(t)) return; |
| 2420 | vmax=zmkompl(s1); |
| 2421 | vumax=zumkompl(u1); |
| 2422 | }else if(c==1&&f==NEGATION){ |
| 2423 | if(!p->left->ntyp) return; |
| 2424 | t=INT; |
| 2425 | if(!ISINT(p->left->ntyp->flags)){ |
| 2426 | if(zldeqto(d1,d2zld(0.0))) vmax=Z1; else vmax=Z0; |
| 2427 | }else if(p->left->ntyp->flags&UNSIGNED){ |
| 2428 | if(zumeqto(u1,ZU0)) vmax=Z1; else vmax=Z0; |
| 2429 | }else |
| 2430 | if(zmeqto(s1,Z0)) vmax=Z1; else vmax=Z0; |
| 2431 | }else |
| 2432 | return; |
| 2433 | |
| 2434 | p->flags=CEXPR; |
| 2435 | if(p->left&&!p->left->sidefx) {free_expression(p->left);p->left=0;} |
| 2436 | if(p->right&&p->right->sidefx) {free_expression(p->right);p->right=0;} |
| 2437 | |
| 2438 | if(ISFLOAT(t)){ |
| 2439 | gval.vldouble=vldouble; |
| 2440 | eval_const(&gval,LDOUBLE); |
| 2441 | }else{ |
| 2442 | if(t&UNSIGNED){ |
| 2443 | gval.vumax=vumax; |
| 2444 | eval_const(&gval,(UNSIGNED|MAXINT)); |
| 2445 | }else{ |
| 2446 | gval.vmax=vmax; |
| 2447 | eval_const(&gval,MAXINT); |
| 2448 | } |
| 2449 | } |
| 2450 | insert_const(&p->val,t); |
| 2451 | if(!p->ntyp){p->ntyp=new_typ();p->ntyp->flags=t;} |
| 2452 | } |
| 2453 | |
| 2454 | |
| 2455 | int alg_opt(np p,type *ttyp) |
| 2456 | /* fuehrt algebraische Vereinfachungen durch */ |
| 2457 | /* hier noch genau testen, was ANSI-gemaess erlaubt ist etc. */ |
| 2458 | /* v.a. Floating-Point ist evtl. kritisch */ |
| 2459 | { |
| 2460 | int c=0,f,komm,null1,null2,eins1,eins2;np merk; |
| 2461 | zldouble d1,d2;zumax u1,u2;zmax s1,s2; |
| 2462 | f=p->flags; |
| 2463 | |
| 2464 | /* do not optimze pointer-pointer */ |
| 2465 | if(f==SUB&&ISPOINTER(p->left->ntyp->flags)&&ISPOINTER(p->right->ntyp->flags)) |
| 2466 | return 1; |
| 2467 | |
| 2468 | /* kommutativ? */ |
| 2469 | if(f==ADD||f==MULT||f==PMULT||(f>=OR&&f<=AND)) komm=1; else komm=0; |
| 2470 | /* Berechnet Wert, wenn beides Konstanten sind */ |
| 2471 | if(p->left->flags==CEXPR||p->left->flags==PCEXPR){ |
| 2472 | eval_constn(p->left); |
| 2473 | d1=vldouble;u1=vumax;s1=vmax;c|=1; |
| 2474 | } |
| 2475 | if(p->right->flags==CEXPR||p->right->flags==PCEXPR){ |
| 2476 | eval_constn(p->right); |
| 2477 | d2=vldouble;u2=vumax;s2=vmax;c|=2; |
| 2478 | } |
| 2479 | if(c==3){ |
| 2480 | p->flags=CEXPR; |
| 2481 | if(DEBUG&1) printf("did simple constant folding\n"); |
| 2482 | if(!p->left->sidefx) {free_expression(p->left);p->left=0;} |
| 2483 | if(!p->right->sidefx) {free_expression(p->right);p->right=0;} |
| 2484 | if(f==AND){ |
| 2485 | vumax=zumand(u1,u2); |
| 2486 | vmax=zmand(s1,s2); |
| 2487 | } |
| 2488 | if(f==OR){ |
| 2489 | vumax=zumor(u1,u2); |
| 2490 | vmax=zmor(s1,s2); |
| 2491 | } |
| 2492 | if(f==XOR){ |
| 2493 | vumax=zumxor(u1,u2); |
| 2494 | vmax=zmxor(s1,s2); |
| 2495 | } |
| 2496 | if(f==ADD){ |
| 2497 | vumax=zumadd(u1,u2); |
| 2498 | vmax=zmadd(s1,s2); |
| 2499 | vldouble=zldadd(d1,d2); |
| 2500 | } |
| 2501 | if(f==SUB){ |
| 2502 | vumax=zumsub(u1,u2); |
| 2503 | vmax=zmsub(s1,s2); |
| 2504 | vldouble=zldsub(d1,d2); |
| 2505 | } |
| 2506 | if(f==MULT||f==PMULT){ |
| 2507 | vumax=zummult(u1,u2); |
| 2508 | vmax=zmmult(s1,s2); |
| 2509 | vldouble=zldmult(d1,d2); |
| 2510 | if(f==PMULT) p->flags=PCEXPR; |
| 2511 | } |
| 2512 | if(f==DIV){ |
| 2513 | if(zmeqto(l2zm(0L),s2)&&zumeqto(ul2zum(0UL),u2)&&zldeqto(d2zld(0.0),d2)){ |
| 2514 | error(84); |
| 2515 | vmax=l2zm(0L);vumax=ul2zum(0UL);vldouble=d2zld(0.0); |
| 2516 | }else{ |
| 2517 | if(!zumeqto(ul2zum(0UL),u2)) vumax=zumdiv(u1,u2); |
| 2518 | if(!zmeqto(l2zm(0L),s2)) vmax=zmdiv(s1,s2); |
| 2519 | if(!zldeqto(d2zld(0.0),d2)) vldouble=zlddiv(d1,d2); |
| 2520 | } |
| 2521 | } |
| 2522 | if(f==MOD){ |
| 2523 | if(zmeqto(l2zm(0L),s2)&&zumeqto(ul2zum(0UL),u2)){ |
| 2524 | error(84); |
| 2525 | vmax=l2zm(0L);vumax=zm2zum(vmax); |
| 2526 | }else{ |
| 2527 | if(!zumeqto(ul2zum(0UL),u2)) vumax=zummod(u1,u2); |
| 2528 | if(!zmeqto(l2zm(0L),s2)) vmax=zmmod(s1,s2); |
| 2529 | } |
| 2530 | } |
| 2531 | if(f==LSHIFT){ |
| 2532 | vumax=zumlshift(u1,u2); |
| 2533 | vmax=zmlshift(s1,s2); |
| 2534 | } |
| 2535 | if(f==RSHIFT){ |
| 2536 | vumax=zumrshift(u1,u2); |
| 2537 | vmax=zmrshift(s1,s2); |
| 2538 | } |
| 2539 | if(ISFLOAT(p->ntyp->flags)){ |
| 2540 | gval.vldouble=vldouble; |
| 2541 | eval_const(&gval,LDOUBLE); |
| 2542 | }else{ |
| 2543 | if(p->ntyp->flags&UNSIGNED){ |
| 2544 | gval.vumax=vumax; |
| 2545 | eval_const(&gval,(UNSIGNED|MAXINT)); |
| 2546 | }else{ |
| 2547 | gval.vmax=vmax; |
| 2548 | eval_const(&gval,MAXINT); |
| 2549 | } |
| 2550 | } |
| 2551 | insert_constn(p); |
| 2552 | return 1; |
| 2553 | } |
| 2554 | /* Konstanten nach rechts, wenn moeglich */ |
| 2555 | if(c==1&&komm){ |
| 2556 | if(DEBUG&1) printf("exchanged commutative constant operand\n"); |
| 2557 | merk=p->left;p->left=p->right;p->right=merk; |
| 2558 | c=2; |
| 2559 | d2=d1;u2=u1;s2=s1; |
| 2560 | } |
| 2561 | /* Vertauscht die Knoten, um Konstanten */ |
| 2562 | /* besser zusammenzufassen (bei allen Type erlaubt?) */ |
| 2563 | /* Hier muss noch einiges kontrolliert werden */ |
| 2564 | if(komm&&c==2&&p->flags==p->left->flags&&(ISINT(p->ntyp->flags)||c_flags[21]&USEDFLAG)){ |
| 2565 | if(p->left->right->flags==CEXPR||p->left->right->flags==PCEXPR){ |
| 2566 | np merk; |
| 2567 | merk=p->right;p->right=p->left->left;p->left->left=merk; |
| 2568 | if(DEBUG&1) printf("Vertausche Add-Nodes\n"); |
| 2569 | dontopt=0; |
| 2570 | return type_expression2(p,ttyp); |
| 2571 | } |
| 2572 | } |
| 2573 | null1=null2=eins1=eins2=0; |
| 2574 | if(c&1){ |
| 2575 | if(zldeqto(d1,d2zld(0.0))&&zumeqto(u1,ul2zum(0UL))&&zmeqto(s1,l2zm(0L))) null1=1; |
| 2576 | if(zldeqto(d1,d2zld(1.0))&&zumeqto(u1,ul2zum(1UL))&&zmeqto(s1,l2zm(1L))) eins1=1; |
| 2577 | if(!(p->ntyp->flags&UNSIGNED)&&zldeqto(d1,d2zld(-1.0))&&zmeqto(s1,l2zm(-1L))) eins1=-1; |
| 2578 | } |
| 2579 | if(c&2){ |
| 2580 | if(zldeqto(d2,d2zld(0.0))&&zumeqto(u2,ul2zum(0UL))&&zmeqto(s2,l2zm(0L))) null2=1; |
| 2581 | if(zldeqto(d2,d2zld(1.0))&&zumeqto(u2,ul2zum(1UL))&&zmeqto(s2,l2zm(1L))) eins2=1; |
| 2582 | if(!(p->ntyp->flags&UNSIGNED)&&zldeqto(d2,d2zld(-1.0))&&zmeqto(s2,l2zm(-1L))) eins2=-1; |
| 2583 | } |
| 2584 | if(c==2){ |
| 2585 | /* a+0=a-0=a^0=a>>0=a<<0=a*1=a/1=a */ |
| 2586 | if(((eins2==1&&(f==MULT||f==PMULT||f==DIV))||(null2&&(f==ADD||f==SUB||f==OR||f==XOR||f==LSHIFT||f==RSHIFT)))&&!p->right->sidefx){ |
| 2587 | if(DEBUG&1){if(f==MULT||f==PMULT||f==DIV) printf("a*/1->a\n"); else printf("a+-^0->a\n");} |
| 2588 | free_expression(p->right); |
| 2589 | merk=p->left; |
| 2590 | *p=*p->left; |
| 2591 | /* freetyp(merk->ntyp); das war Fehler */ |
| 2592 | free(merk); |
| 2593 | dontopt=0; |
| 2594 | return type_expression2(p,ttyp); |
| 2595 | } |
| 2596 | /* a*0=0 */ |
| 2597 | if(null2&&(f==MULT||f==PMULT||f==AND||f==DIV||f==MOD)){ |
| 2598 | if(DEBUG&1) printf("a*&/%%0->0\n"); |
| 2599 | if(null2&&(f==DIV||f==MOD)) error(84); |
| 2600 | if(p->flags==PMULT) p->flags=PCEXPR; else p->flags=CEXPR; |
| 2601 | gval.vint=zm2zi(l2zm(0L)); |
| 2602 | eval_const(&gval,INT); |
| 2603 | /* hier nur int,long,float,double moeglich, hoffe ich */ |
| 2604 | insert_constn(p); |
| 2605 | if(!p->left->sidefx){free_expression(p->left);p->left=0;} else make_cexpr(p->left); |
| 2606 | if(!p->right->sidefx){free_expression(p->right);p->right=0;} else make_cexpr(p->right); |
| 2607 | |
| 2608 | /* return(type_expression2(p,ttyp)); */ |
| 2609 | return 1; |
| 2610 | } |
| 2611 | if(eins2==-1&&(f==MULT||f==PMULT||f==DIV)&&!p->right->sidefx){ |
| 2612 | if(DEBUG&1) printf("a*/(-1)->-a\n"); |
| 2613 | free_expression(p->right); |
| 2614 | p->right=0; |
| 2615 | p->flags=MINUS; |
| 2616 | dontopt=0; |
| 2617 | return type_expression2(p,ttyp); |
| 2618 | } |
| 2619 | /* check volatile */ |
| 2620 | if(0) /* TODO: make this efficient */ |
| 2621 | { |
| 2622 | type st={0}; |
| 2623 | if(!zmeqto(sizetab[CHAR],sizetab[SHORT])){ |
| 2624 | //if(f==AND&&(!ttyp||(ttyp->flags&NQ)>CHAR)&&shortcut(AND,CHAR)&&zumleq(u2,t_max[CHAR])) |
| 2625 | //st.flags=CHAR; |
| 2626 | if(f==AND&&(!ttyp||(ttyp->flags&NQ)>CHAR)/*&&(p->ntyp->flags&UNSIGNED)*/&&shortcut(AND,UNSIGNED|CHAR)&&zumleq(u2,tu_max[CHAR])) |
| 2627 | st.flags=UNSIGNED|CHAR; |
| 2628 | } |
| 2629 | if(!zmeqto(sizetab[SHORT],sizetab[INT])){ |
| 2630 | //if(f==AND&&(!ttyp||(ttyp->flags&NQ)>SHORT)&&shortcut(AND,SHORT)&&zumleq(s2,t_max[SHORT])) |
| 2631 | //st.flags=SHORT; |
| 2632 | if(f==AND&&(!ttyp||(ttyp->flags&NQ)>SHORT)/*&&(p->ntyp->flags&UNSIGNED)*/&&shortcut(AND,UNSIGNED|SHORT)&&zumleq(u2,tu_max[SHORT])) |
| 2633 | st.flags=UNSIGNED|SHORT; |
| 2634 | } |
| 2635 | //if(!ttyp&&(p->left->ntyp->flags&NQ)>INT) st.flags=0; |
| 2636 | if(st.flags){ |
| 2637 | int ret;type *otyp;np n; |
| 2638 | if(!p->ntyp) ierror(0); |
| 2639 | otyp=clone_typ(p->ntyp); |
| 2640 | n=new_node(); |
| 2641 | n->left=p->left; |
| 2642 | n->right=0; |
| 2643 | n->flags=CAST; |
| 2644 | n->ntyp=clone_typ(&st); |
| 2645 | eval_const(&p->right->val,p->right->ntyp->flags); |
| 2646 | p->right->ntyp->flags=st.flags; |
| 2647 | insert_const(&p->right->val,st.flags); |
| 2648 | p->left=n; |
| 2649 | n=new_node(); |
| 2650 | *n=*p; |
| 2651 | p->left=n; |
| 2652 | p->right=0; |
| 2653 | p->flags=CAST; |
| 2654 | p->ntyp=otyp; |
| 2655 | ret=type_expression2(p->left,&st); |
| 2656 | |
| 2657 | return ret; |
| 2658 | } |
| 2659 | } |
| 2660 | |
| 2661 | } |
| 2662 | if(c==1){ |
| 2663 | /* 0-a=-a */ |
| 2664 | if(f==SUB&&null1&&!p->left->sidefx){ |
| 2665 | if(DEBUG&1) printf("0-a->-a\n"); |
| 2666 | free_expression(p->left); |
| 2667 | p->flags=MINUS; |
| 2668 | p->left=p->right; |
| 2669 | p->right=0; |
| 2670 | dontopt=0; |
| 2671 | return type_expression2(p,ttyp); |
| 2672 | } |
| 2673 | /* 0/a=0 */ |
| 2674 | if(null1&&(f==DIV||f==MOD||f==LSHIFT||f==RSHIFT)){ |
| 2675 | if(DEBUG&1) printf("0/%%<<>>a->0\n"); |
| 2676 | p->flags=CEXPR; |
| 2677 | gval.vint=zm2zi(l2zm(0L)); |
| 2678 | eval_const(&gval,INT); |
| 2679 | insert_constn(p); |
| 2680 | if(!p->left->sidefx){free_expression(p->left);p->left=0;}else make_cexpr(p->left); |
| 2681 | if(!p->right->sidefx){free_expression(p->right);p->right=0;} else make_cexpr(p->right); |
| 2682 | dontopt=0; |
| 2683 | return type_expression2(p,ttyp); |
| 2684 | } |
| 2685 | } |
| 2686 | return 1; |
| 2687 | } |
| 2688 | void make_cexpr(np p) |
| 2689 | /* Macht aus einem Knoten, der durch constant-folding ueberfluessig */ |
| 2690 | /* wurde, eine PCEXPR, sofern er keine Nebenwirkungen von sich aus */ |
| 2691 | /* erzeugt. Hier noch ueberpruefen, ob CEXPR besser waere. */ |
| 2692 | /* Fuehrt rekursiven Abstieg durch. Ist das so korrekt? */ |
| 2693 | { |
| 2694 | int f=p->flags; |
| 2695 | if(f!=ASSIGN&&f!=ASSIGNOP&&f!=CALL&&f!=POSTINC&&f!=POSTDEC&&f!=PREINC&&f!=PREDEC&&f!=LAND&&f!=LOR){ |
| 2696 | p->flags=PCEXPR; |
| 2697 | if(p->left) make_cexpr(p->left); |
| 2698 | if(p->right) make_cexpr(p->right); |
| 2699 | } |
| 2700 | } |
| 2701 | int test_assignment(type *zt,np q) |
| 2702 | /* testet, ob q an Typ z zugewiesen werden darf */ |
| 2703 | { |
| 2704 | type *qt=q->ntyp; |
| 2705 | if(ISARITH(zt->flags)&&ISARITH(qt->flags)){ |
| 2706 | if(ISINT(zt->flags)&&ISINT(qt->flags)&& |
| 2707 | !zmleq(sizetab[qt->flags&NQ],sizetab[zt->flags&NQ])&&q->flags!=CEXPR){ |
| 2708 | #ifdef HAVE_MISRA |
| 2709 | /* removed */ |
| 2710 | #endif |
| 2711 | error(166); |
| 2712 | } |
| 2713 | if(q->flags==CEXPR){ |
| 2714 | zmax ms,ns;zumax mu,nu; |
| 2715 | eval_constn(q); |
| 2716 | ms=vmax;mu=vumax; |
| 2717 | insert_const(&gval,zt->flags&~UNSIGNED); |
| 2718 | eval_const(&gval,zt->flags&~UNSIGNED); |
| 2719 | ns=vmax; |
| 2720 | eval_constn(q); |
| 2721 | insert_const(&gval,zt->flags|UNSIGNED); |
| 2722 | eval_const(&gval,zt->flags|UNSIGNED); |
| 2723 | nu=vumax; |
| 2724 | if(!zumeqto(nu,mu)&&!zmeqto(ns,ms)) |
| 2725 | error(363); |
| 2726 | else{ |
| 2727 | if(zt->flags&UNSIGNED){ |
| 2728 | if(!zumeqto(nu,mu)) |
| 2729 | error(362); |
| 2730 | }else{ |
| 2731 | if(!zmeqto(ns,ms)) |
| 2732 | error(362); |
| 2733 | } |
| 2734 | } |
| 2735 | } |
| 2736 | return 1; |
| 2737 | } |
| 2738 | if((ISSTRUCT(zt->flags)&&ISSTRUCT(qt->flags))|| |
| 2739 | (ISUNION(zt->flags)&&ISUNION(qt->flags))){ |
| 2740 | if(!compatible_types(zt,qt,NU)){ |
| 2741 | error(38); |
| 2742 | return 0; |
| 2743 | }else |
| 2744 | return 1; |
| 2745 | } |
| 2746 | if(ISVECTOR(zt->flags)&&(zt->flags&NU)==(qt->flags&NU)){ |
| 2747 | return 1; |
| 2748 | } |
| 2749 | if(ISPOINTER(zt->flags)&&ISPOINTER(qt->flags)){ |
| 2750 | if((zt->next->flags&NQ)==VOID&&!ISFUNC(qt->next->flags)) return 1; |
| 2751 | if((qt->next->flags&NQ)==VOID&&!ISFUNC(qt->next->flags)) return 1; |
| 2752 | if(!compatible_types(zt->next,qt->next,(c_flags[7]&USEDFLAG)?NU:NQ)){ |
| 2753 | if(!ecpp){ |
| 2754 | error(85); |
| 2755 | } |
| 2756 | #ifdef HAVE_ECPP |
| 2757 | /* removed */ |
| 2758 | /* removed */ |
| 2759 | /* removed */ |
| 2760 | /* removed */ |
| 2761 | /* removed */ |
| 2762 | /* removed */ |
| 2763 | /* removed */ |
| 2764 | /* removed */ |
| 2765 | /* removed */ |
| 2766 | /* removed */ |
| 2767 | /* removed */ |
| 2768 | /* removed */ |
| 2769 | /* removed */ |
| 2770 | /* removed */ |
| 2771 | /* removed */ |
| 2772 | /* removed */ |
| 2773 | /* removed */ |
| 2774 | /* removed */ |
| 2775 | /* removed */ |
| 2776 | /* removed */ |
| 2777 | /* removed */ |
| 2778 | /* removed */ |
| 2779 | /* removed */ |
| 2780 | /* removed */ |
| 2781 | /* removed */ |
| 2782 | #endif |
| 2783 | }else{ |
| 2784 | if((qt->next->flags&CONST)&&!(zt->next->flags&CONST)) |
| 2785 | error(91); |
| 2786 | if((qt->next->flags&VOLATILE)&&!(zt->next->flags&VOLATILE)) |
| 2787 | error(100); |
| 2788 | if((qt->next->flags&RESTRICT)&&!(zt->next->flags&RESTRICT)) |
| 2789 | error(298); |
| 2790 | if(qt->next->next&&zt->next->next&&!compatible_types(zt->next->next,qt->next->next,NU)) |
| 2791 | error(110); |
| 2792 | } |
| 2793 | return 1; |
| 2794 | } |
| 2795 | if(ISPOINTER(zt->flags)&&q->flags==CEXPR){ |
| 2796 | eval_constn(q); |
| 2797 | if(!(zldeqto(d2zld(0.0),vldouble)&&zmeqto(l2zm(0L),vmax)&&zumeqto(ul2zum(0UL),vumax))) |
| 2798 | error(113); |
| 2799 | return 1; |
| 2800 | } |
| 2801 | error(39); |
| 2802 | return 0; |
| 2803 | } |
| 2804 | #ifdef HAVE_ECPP |
| 2805 | /* removed */ |
| 2806 | /* removed */ |
| 2807 | /* removed */ |
| 2808 | /* removed */ |
| 2809 | /* removed */ |
| 2810 | /* removed */ |
| 2811 | /* removed */ |
| 2812 | /* removed */ |
| 2813 | /* removed */ |
| 2814 | /* removed */ |
| 2815 | /* removed */ |
| 2816 | /* removed */ |
| 2817 | /* removed */ |
| 2818 | /* removed */ |
| 2819 | /* removed */ |
| 2820 | /* removed */ |
| 2821 | /* removed */ |
| 2822 | /* removed */ |
| 2823 | /* removed */ |
| 2824 | /* removed */ |
| 2825 | /* removed */ |
| 2826 | /* removed */ |
| 2827 | /* removed */ |
| 2828 | /* removed */ |
| 2829 | /* removed */ |
| 2830 | /* removed */ |
| 2831 | /* removed */ |
| 2832 | /* removed */ |
| 2833 | /* removed */ |
| 2834 | /* removed */ |
| 2835 | /* removed */ |
| 2836 | /* removed */ |
| 2837 | /* removed */ |
| 2838 | /* removed */ |
| 2839 | /* removed */ |
| 2840 | /* removed */ |
| 2841 | /* removed */ |
| 2842 | /* removed */ |
| 2843 | /* removed */ |
| 2844 | /* removed */ |
| 2845 | /* removed */ |
| 2846 | /* removed */ |
| 2847 | /* removed */ |
| 2848 | /* removed */ |
| 2849 | /* removed */ |
| 2850 | /* removed */ |
| 2851 | /* removed */ |
| 2852 | /* removed */ |
| 2853 | /* removed */ |
| 2854 | /* removed */ |
| 2855 | /* removed */ |
| 2856 | /* removed */ |
| 2857 | /* removed */ |
| 2858 | /* removed */ |
| 2859 | /* removed */ |
| 2860 | /* removed */ |
| 2861 | /* removed */ |
| 2862 | /* removed */ |
| 2863 | /* removed */ |
| 2864 | /* removed */ |
| 2865 | /* removed */ |
| 2866 | /* removed */ |
| 2867 | /* removed */ |
| 2868 | /* removed */ |
| 2869 | /* removed */ |
| 2870 | /* removed */ |
| 2871 | /* removed */ |
| 2872 | /* removed */ |
| 2873 | /* removed */ |
| 2874 | /* removed */ |
| 2875 | /* removed */ |
| 2876 | /* removed */ |
| 2877 | /* removed */ |
| 2878 | /* removed */ |
| 2879 | /* removed */ |
| 2880 | /* removed */ |
| 2881 | /* removed */ |
| 2882 | /* removed */ |
| 2883 | /* removed */ |
| 2884 | /* removed */ |
| 2885 | /* removed */ |
| 2886 | /* removed */ |
| 2887 | /* removed */ |
| 2888 | /* removed */ |
| 2889 | /* removed */ |
| 2890 | /* removed */ |
| 2891 | /* removed */ |
| 2892 | /* removed */ |
| 2893 | /* removed */ |
| 2894 | /* removed */ |
| 2895 | /* removed */ |
| 2896 | /* removed */ |
| 2897 | /* removed */ |
| 2898 | /* removed */ |
| 2899 | /* removed */ |
| 2900 | /* removed */ |
| 2901 | /* removed */ |
| 2902 | /* removed */ |
| 2903 | /* removed */ |
| 2904 | /* removed */ |
| 2905 | /* removed */ |
| 2906 | /* removed */ |
| 2907 | /* removed */ |
| 2908 | /* removed */ |
| 2909 | /* removed */ |
| 2910 | /* removed */ |
| 2911 | /* removed */ |
| 2912 | /* removed */ |
| 2913 | /* removed */ |
| 2914 | /* removed */ |
| 2915 | /* removed */ |
| 2916 | /* removed */ |
| 2917 | /* removed */ |
| 2918 | /* removed */ |
| 2919 | /* removed */ |
| 2920 | /* removed */ |
| 2921 | /* removed */ |
| 2922 | /* removed */ |
| 2923 | /* removed */ |
| 2924 | /* removed */ |
| 2925 | /* removed */ |
| 2926 | /* removed */ |
| 2927 | /* removed */ |
| 2928 | /* removed */ |
| 2929 | /* removed */ |
| 2930 | /* removed */ |
| 2931 | /* removed */ |
| 2932 | /* removed */ |
| 2933 | /* removed */ |
| 2934 | /* removed */ |
| 2935 | /* removed */ |
| 2936 | /* removed */ |
| 2937 | /* removed */ |
| 2938 | /* removed */ |
| 2939 | /* removed */ |
| 2940 | /* removed */ |
| 2941 | /* removed */ |
| 2942 | /* removed */ |
| 2943 | /* removed */ |
| 2944 | /* removed */ |
| 2945 | /* removed */ |
| 2946 | /* removed */ |
| 2947 | /* removed */ |
| 2948 | /* removed */ |
| 2949 | /* removed */ |
| 2950 | /* removed */ |
| 2951 | /* removed */ |
| 2952 | /* removed */ |
| 2953 | /* removed */ |
| 2954 | /* removed */ |
| 2955 | /* removed */ |
| 2956 | /* removed */ |
| 2957 | /* removed */ |
| 2958 | /* removed */ |
| 2959 | /* removed */ |
| 2960 | /* removed */ |
| 2961 | /* removed */ |
| 2962 | /* removed */ |
| 2963 | /* removed */ |
| 2964 | /* removed */ |
| 2965 | /* removed */ |
| 2966 | /* removed */ |
| 2967 | /* removed */ |
| 2968 | /* removed */ |
| 2969 | /* removed */ |
| 2970 | /* removed */ |
| 2971 | /* removed */ |
| 2972 | /* removed */ |
| 2973 | /* removed */ |
| 2974 | /* removed */ |
| 2975 | /* removed */ |
| 2976 | /* removed */ |
| 2977 | /* removed */ |
| 2978 | /* removed */ |
| 2979 | /* removed */ |
| 2980 | /* removed */ |
| 2981 | /* removed */ |
| 2982 | /* removed */ |
| 2983 | /* removed */ |
| 2984 | /* removed */ |
| 2985 | /* removed */ |
| 2986 | /* removed */ |
| 2987 | /* removed */ |
| 2988 | /* removed */ |
| 2989 | /* removed */ |
| 2990 | /* removed */ |
| 2991 | /* removed */ |
| 2992 | /* removed */ |
| 2993 | /* removed */ |
| 2994 | /* removed */ |
| 2995 | /* removed */ |
| 2996 | /* removed */ |
| 2997 | /* removed */ |
| 2998 | /* removed */ |
| 2999 | /* removed */ |
| 3000 | /* removed */ |
| 3001 | /* removed */ |
| 3002 | /* removed */ |
| 3003 | /* removed */ |
| 3004 | /* removed */ |
| 3005 | /* removed */ |
| 3006 | /* removed */ |
| 3007 | /* removed */ |
| 3008 | /* removed */ |
| 3009 | /* removed */ |
| 3010 | /* removed */ |
| 3011 | /* removed */ |
| 3012 | /* removed */ |
| 3013 | /* removed */ |
| 3014 | /* removed */ |
| 3015 | /* removed */ |
| 3016 | /* removed */ |
| 3017 | /* removed */ |
| 3018 | /* removed */ |
| 3019 | /* removed */ |
| 3020 | /* removed */ |
| 3021 | /* removed */ |
| 3022 | /* removed */ |
| 3023 | /* removed */ |
| 3024 | /* removed */ |
| 3025 | /* removed */ |
| 3026 | /* removed */ |
| 3027 | /* removed */ |
| 3028 | /* removed */ |
| 3029 | /* removed */ |
| 3030 | /* removed */ |
| 3031 | /* removed */ |
| 3032 | /* removed */ |
| 3033 | /* removed */ |
| 3034 | /* removed */ |
| 3035 | /* removed */ |
| 3036 | /* removed */ |
| 3037 | /* removed */ |
| 3038 | /* removed */ |
| 3039 | /* removed */ |
| 3040 | /* removed */ |
| 3041 | /* removed */ |
| 3042 | /* removed */ |
| 3043 | /* removed */ |
| 3044 | /* removed */ |
| 3045 | /* removed */ |
| 3046 | /* removed */ |
| 3047 | /* removed */ |
| 3048 | /* removed */ |
| 3049 | /* removed */ |
| 3050 | /* removed */ |
| 3051 | /* removed */ |
| 3052 | /* removed */ |
| 3053 | /* removed */ |
| 3054 | /* removed */ |
| 3055 | /* removed */ |
| 3056 | /* removed */ |
| 3057 | /* removed */ |
| 3058 | /* removed */ |
| 3059 | /* removed */ |
| 3060 | /* removed */ |
| 3061 | /* removed */ |
| 3062 | /* removed */ |
| 3063 | /* removed */ |
| 3064 | /* removed */ |
| 3065 | /* removed */ |
| 3066 | /* removed */ |
| 3067 | /* removed */ |
| 3068 | /* removed */ |
| 3069 | /* removed */ |
| 3070 | /* removed */ |
| 3071 | /* removed */ |
| 3072 | /* removed */ |
| 3073 | /* removed */ |
| 3074 | /* removed */ |
| 3075 | /* removed */ |
| 3076 | /* removed */ |
| 3077 | /* removed */ |
| 3078 | /* removed */ |
| 3079 | /* removed */ |
| 3080 | /* removed */ |
| 3081 | /* removed */ |
| 3082 | /* removed */ |
| 3083 | /* removed */ |
| 3084 | /* removed */ |
| 3085 | /* removed */ |
| 3086 | /* removed */ |
| 3087 | /* removed */ |
| 3088 | /* removed */ |
| 3089 | /* removed */ |
| 3090 | #endif |