Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.258
 
1.259
 
MAIN:ragge:20101013195517
 
trees.c
_>13361336 
 13371337 int tdebug = 0;
 13381338 
<>1339 -NODE *
 1340 -tymatch(pregister NODE *p; {
13411339 
<>1342 -        /* satisfy the types of various arithmetic binary ops */
 1343 -
 1344 -        /* rules are:
 1345 -                if assignment, type of LHS
 1346 -                if any doubles, make double
 1347 -                else if any float make float
 1348 -                else if any longlongs, make long long
 1349 -                else if any longs, make long
 1350 -                else etcetc.
 1351 -                if either operand is unsigned, the result is...
 1352 -        */
 1353 -
 1354 -        TWORD t1, t2, t, tu;
  1340+/*
  1341+ * Satisfy the types of various arithmetic binary ops.
  1342+ *
  1343+ * rules are:
  1344+ *  if assignment, type of LHS
  1345+ *  if any doubles, make double
  1346+ *  else if any float make float
  1347+ *  else if any longlongs, make long long
  1348+ *  else if any longs, make long
  1349+ *  else etcetc.
  1350+ *
  1351+ *  If the op with the highest rank is unsigned, this is the resulting type.
  1352+ *  See:  6.3.1.1 rank order equal of signed and unsigned types
  1353+ *        6.3.1.8 Usual arithmetic conversions
  1354+ */
  1355+NODE *
  1356+tymatch(NODE *p)
  1357+{
  1358+        TWORD tl, tr, t, tu;
  1359+        NODE *l, *r;
13551360         int o, lu, ru;
 13561361 
 13571362         o = p->n_op;
<> 1363+        r = p->n_right;
  1364+        l = p->n_left;
13581365 
<>1359 -        t1 = p->n_left->n_type;
 1360 -        t2 = p->n_right->n_type;
  1366+        tl = l->n_type;
  1367+        tr = r->n_type;
13611368 
 13621369         lu = ru = 0;
<>1363 -        if( ISUNSIGNED(t1) ){
  1370+        if (ISUNSIGNED(tl)) {
13641371                 lu = 1;
<>1365 -                t1 = DEUNSIGN(t1);
 1366 -                }
 1367 -        if( ISUNSIGNED(t2) ){
  1372+                tl = DEUNSIGN(tl);
  1373+        }
  1374+        if (ISUNSIGNED(tr)) {
13681375                 ru = 1;
<>1369 -                t2 = DEUNSIGN(t2);
 1370 -                }
  1376+                tr = DEUNSIGN(tr);
  1377+        }
13711378 
<>1372 -        if (Wsign_compare && clogop(o) && t1 == t2 && lu != ru &&
 1373 -            p->n_left->n_op != ICON && p->n_right->n_op != ICON)
  1379+        if (Wsign_compare && clogop(o) && tl == tr && lu != ru &&
  1380+            l->n_op != ICON && r->n_op != ICON)
13741381                 werror("comparison between signed and unsigned");
 13751382 
<>1376 -#if 0
 1377 -        if ((t1 == CHAR || t1 == SHORT) && o!= RETURN)
 1378 -                t1 = INT;
 1379 -        if (t2 == CHAR || t2 == SHORT)
 1380 -                t2 = INT;
 1381 -#endif
 1382 -
 1383 -        if (t1 == LDOUBLE || t2 == LDOUBLE)
  1383+        if (tl == LDOUBLE || tr == LDOUBLE)
13841384                 t = LDOUBLE;
<>1385 -        else if (t1 == DOUBLE || t2 == DOUBLE)
  1385+        else if (tl == DOUBLE || tr == DOUBLE)
13861386                 t = DOUBLE;
<>1387 -        else if (t1 == FLOAT || t2 == FLOAT)
  1387+        else if (tl == FLOAT || tr == FLOAT)
13881388                 t = FLOAT;
<>1389 -        else if (t1==LONGLONG || t2 == LONGLONG)
  1389+        else if (tl==LONGLONG || tr == LONGLONG)
13901390                 t = LONGLONG;
<>1391 -        else if (t1==LONG || t2==LONG)
  1391+        else if (tl==LONG || tr==LONG)
13921392                 t = LONG;
<>1393 -        else /* if (t1==INT || t2==INT) */
  1393+        else /* everything else */
13941394                 t = INT;
<>1395 -#if 0
 1396 -        else if (t1==SHORT || t2==SHORT)
 1397 -                t = SHORT;
 1398 -        else
 1399 -                t = CHAR;
 1400 -#endif
14011395 
<>1402 -        if( casgop(o) ){
 1403 -                tu = p->n_left->n_type;
 1404 -                t = t1;
  1396+        if (casgop(o)) {
  1397+                tu = l->n_type;
  1398+                t = tl;
14051399         } else {
<>1406 -                tu = ((ru|lu) && UNSIGNABLE(t))?ENUNSIGN(t):t;
  1400+                /* Should result be unsigned? */
  1401+                /* This depends on ctype() being called correctly */
  1402+                tu = t;
  1403+                if (UNSIGNABLE(t) && (lu || ru)) {
  1404+                        if (tl >= tr && lu)
  1405+                                tu = ENUNSIGN(t);
  1406+                        if (tr >= tl && ru)
  1407+                                tu = ENUNSIGN(t);
  1408+                }
14071409         }
 14081410 
 14091411         /* because expressions have values that are at least as wide
 14101412            as INT or UNSIGNED, the only conversions needed
 14111413            are those involving FLOAT/DOUBLE, and those
 14121414            from LONG to INT and ULONG to UNSIGNED */
 14131415 
<>1414 -        if (t != t1 || (ru && !lu)) {
 1415 -                if (Wtruncate && o != CAST && p->n_right->n_op != ICON &&
 1416 -                    tsize(t1, 0, MKAP(t2)) > tsize(tu, 0, MKAP(tu)))
  1416+        if (t != tl || (ru && !lu)) {
  1417+                if (Wtruncate && o != CAST && r->n_op != ICON &&
  1418+                    tsize(tl, 0, MKAP(tl)) > tsize(tu, 0, MKAP(tu)))
14171419                         werror("conversion to '%s' from '%s' may alter its value",
<>1418 -                            tnames[tu], tnames[t1]);
  1420+                            tnames[tu], tnames[tl]);
14191421                 p->n_left = makety( p->n_left, tu, 0, 0, MKAP(tu));
 14201422         }
 14211423 
<>1422 -        if (t != t2 || o==CAST || (lu && !ru)) {
 1423 -                if (Wtruncate && o != CAST && p->n_right->n_op != ICON &&
 1424 -                    tsize(t2, 0, MKAP(t2)) > tsize(tu, 0, MKAP(tu)))
  1424+        if (t != tr || o==CAST || (lu && !ru)) {
  1425+                if (Wtruncate && o != CAST && r->n_op != ICON &&
  1426+                    tsize(tr, 0, MKAP(tr)) > tsize(tu, 0, MKAP(tu)))
14251427                         werror("conversion to '%s' from '%s' may alter its value",
<>1426 -                            tnames[tu], tnames[t2]);
  1428+                            tnames[tu], tnames[tr]);
14271429                 p->n_right = makety(p->n_right, tu, 0, 0, MKAP(tu));
 14281430         }
 14291431 
     
 !
14411443 #ifdef PCC_DEBUG
 14421444         if (tdebug) {
 14431445                 printf("tymatch(%p): ", p);
<>1444 -                tprint(stdout, t1, 0);
  1446+                tprint(stdout, tl, 0);
14451447                 printf(" %s ", copst(o));
<>1446 -                tprint(stdout, t2, 0);
  1448+                tprint(stdout, tr, 0);
<_14471449                 printf(" => ");
 14481450                 tprint(stdout, tu, 0);
 14491451                 printf("\n");
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-09-16 11:30 +0200