Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.289
 
1.290
 
MAIN:ragge:20110629194621
 
trees.c
_>7777 static int moditype(TWORD);
 7878 static NODE *strargs(NODE *);
 7979 static void rmcops(NODE *p);
<> 80+static NODE *tymatch(NODE *p);
8081 void putjops(NODE *, void *);
 8182 static struct symtab *findmember(struct symtab *, char *);
 8283 int inftn; /* currently between epilog/prolog */
     
 !
14641465 
 14651466 int tdebug = 0;
 14661467 
<>1467 -
14681468 /*
 14691469  * Satisfy the types of various arithmetic binary ops.
 14701470  *
     
 !
14781478  *
 14791479  *  If the op with the highest rank is unsigned, this is the resulting type.
 14801480  *  See:  6.3.1.1 rank order equal of signed and unsigned types
<>1481 - *        6.3.1.8 Usual arithmetic conversions
  1481+ *        6.3.1.8 Usual arithmetic conversions
14821482  */
<>1483 -NODE *
  1483+static NODE *
14841484 tymatch(NODE *p)
 14851485 {
<>1486 -        TWORD tl, tr, t, tu;
  1486+        TWORD tl, tr, t;
14871487         NODE *l, *r;
<>1488 -        int o, lu, ru;
  1488+        int o;
14891489 
 14901490         o = p->n_op;
 14911491         r = p->n_right;
     
 !
14971497         if (tl == BOOL) tl = BOOL_TYPE;
 14981498         if (tr == BOOL) tr = BOOL_TYPE;
 14991499 
<>1500 -        lu = ru = 0;
 1501 -        if (ISUNSIGNED(tl)) {
 1502 -                lu = 1;
 1503 -                tl = DEUNSIGN(tl);
 1504 -        }
 1505 -        if (ISUNSIGNED(tr)) {
 1506 -                ru = 1;
 1507 -                tr = DEUNSIGN(tr);
 1508 -        }
 1509 -
 1510 -        if (clogop(o) && tl == tr && lu != ru &&
 1511 -            l->n_op != ICON && r->n_op != ICON)
 1512 -                warner(Wsign_compare, NULL);
 1513 -
 1514 -        if (tl == LDOUBLE || tr == LDOUBLE)
 1515 -                t = LDOUBLE;
 1516 -        else if (tl == DOUBLE || tr == DOUBLE)
 1517 -                t = DOUBLE;
 1518 -        else if (tl == FLOAT || tr == FLOAT)
 1519 -                t = FLOAT;
 1520 -        else if (tl==LONGLONG || tr == LONGLONG)
 1521 -                t = LONGLONG;
 1522 -        else if (tl==LONG || tr==LONG)
 1523 -                t = LONG;
 1524 -        else /* everything else */
 1525 -                t = INT;
 1526 -
15271500         if (casgop(o)) {
<>1528 -                tu = l->n_type;
 1529 -                t = tl;
  1501+                if (r->n_op != ICON && tl < FLOAT && tr < FLOAT &&
  1502+                    DEUNSIGN(tl) < DEUNSIGN(tr))
  1503+                        warner(Wtruncate, tnames[tr], tnames[tl]);
  1504+                p->n_right = makety(p->n_right, l->n_type, 0, 0, 0);
  1505+                t = p->n_type = l->n_type;
  1506+                p->n_ap = l->n_ap;
15301507         } else {
<>1531 -                /* Should result be unsigned? */
 1532 -                /* This depends on ctype() being called correctly */
 1533 -                tu = t;
 1534 -                if (UNSIGNABLE(t) && (lu || ru)) {
 1535 -                        if (tl >= tr && lu)
 1536 -                                tu = ENUNSIGN(t);
 1537 -                        if (tr >= tl && ru)
 1538 -                                tu = ENUNSIGN(t);
 1539 -                }
  1508+                t = tl > tr ? tl : tr; /* MAX */
  1509+                /* This depends on ctype() called early */
  1510+                if (o != COLON && t < INT)
  1511+                        t = INT;
  1512+                if (tl != t) p->n_left = makety(p->n_left, t, 0, 0, 0);
  1513+                if (tr != t) p->n_right = makety(p->n_right, t, 0, 0, 0);
  1514+                if (o == COLON && l->n_type == BOOL && r->n_type == BOOL)
  1515+                        t = p->n_type = BOOL;
  1516+                else if (!clogop(o))
  1517+                        p->n_type = t;
15401518         }
<>1541 -
 1542 -        /* because expressions have values that are at least as wide
 1543 -           as INT or UNSIGNED, the only conversions needed
 1544 -           are those involving FLOAT/DOUBLE, and those
 1545 -           from LONG to INT and ULONG to UNSIGNED */
 1546 -
 1547 -        if (t != tl || (ru && !lu)) {
 1548 -                if (o != CAST && r->n_op != ICON &&
 1549 -                    tsize(tl, 0, 0) > tsize(tu, 0, 0))
 1550 -                        warner(Wtruncate, tnames[tu], tnames[tl]);
 1551 -                p->n_left = makety( p->n_left, tu, 0, 0, 0);
 1552 -        }
 1553 -
 1554 -        if (t != tr || o==CAST || (lu && !ru)) {
 1555 -                if (o != CAST && r->n_op != ICON &&
 1556 -                    tsize(tr, 0, 0) > tsize(tu, 0, 0))
 1557 -                        warner(Wtruncate, tnames[tu], tnames[tr]);
 1558 -                p->n_right = makety(p->n_right, tu, 0, 0, 0);
 1559 -        }
 1560 -
 1561 -        if( casgop(o) ){
 1562 -                p->n_type = p->n_left->n_type;
 1563 -                p->n_df = p->n_left->n_df;
 1564 -                p->n_ap = p->n_left->n_ap;
 1565 -                }
 1566 -        else if( !clogop(o) ){
 1567 -                p->n_type = tu;
 1568 -                p->n_df = NULL;
 1569 -                p->n_ap = NULL;
 1570 -                }
 1571 -
15721519 #ifdef PCC_DEBUG
 15731520         if (tdebug) {
 15741521                 printf("tymatch(%p): ", p);
 15751522                 tprint(stdout, tl, 0);
 15761523                 printf(" %s ", copst(o));
 15771524                 tprint(stdout, tr, 0);
 15781525                 printf(" => ");
<>1579 -                tprint(stdout, tu, 0);
  1526+                tprint(stdout, t, 0);
15801527                 printf("\n");
 15811528                 fwalk(p, eprint, 0);
 15821529         }
 15831530 #endif
<>1584 -
 1585 -        return(p);
  1531+        return p;
<_15861532 }
 15871533 
 15881534 /*
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-08-28 05:06 +0200