Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.29
 
1.30
 
MAIN:ragge:20030612092208
 
trees.c
_>1 -#if 0
 2 -static char *sccsid ="@(#)trees.c       4.37 (Berkeley) 6/18/90";
 3 -#endif
 4 -
51 # include "pass1.h"
 62 # include "pass2.h"     /* for NOPREF */
 73 
 84 # include <setjmp.h>
 95 # include <stdarg.h>
 106 # include <string.h>
 117 
<>12 -int bdebug = 0;
 13 -int adebug = 0;
 14 -extern int ddebug;
  8+int adebug = 0/* XXX 4.4 */
  9+extern int ddebug;      /* XXX 4.4 */
1510 
 1611 void chkpun(NODE *p);
 1712 int opact(NODE *p);
<>18 -int chkstr(int, int, TWORD);
1913 int moditype(TWORD);
 2014 static void to_pass2(NODE *p);
 2115 
     
 !
3731 
 3832 #ifndef BUG1
 3933 static void
<>40 -printact(NODE *t, int acts)
  34+printact(NODE *t, int acts)     /* XXX 4.4  hela printact */
4135 {
 4236         static struct actions {
 4337                 int     a_bit;
     
 !
8781 
 8882         */
 8983 
<> 84+int bdebug = 0;
  85+
9086 NODE *
 9187 buildtree(int o, NODE *l, NODE *r)
 9288 {
     
 !
119115                         }
 120116                 }
 121117 
<> 118+        /* XXX 4.4  följande sats */
122119         else if( opty == UTYPE && (l->n_op == FCON || l->n_op == DCON) ){
 123120 
 124121                 switch( o ){
     
 !
171168                 case LE:
 172169                 case GE:
 173170                 case EQ:
<>174 -                case NE:
  171+                case NE:        /* XXX 4.4 nedanstanende sats */
175172                         if( l->n_type == ENUMTY && r->n_type == ENUMTY ){
 176173                                 p = block(o, l, r, INT, 0, MKSUE(INT));
 177174                                 chkpun( p );
     
 !
201198                         break;
 202199                         }
 203200                 }
<>204 -        else if (opty == BITYPE &&
  201+        else if (opty == BITYPE &&      /* XXX 4.4 DCON-tillägget */
205202                 (l->n_op == FCON || l->n_op == DCON || l->n_op == ICON) &&
 206203                 (r->n_op == FCON || r->n_op == DCON || r->n_op == ICON)) {
 207204                         if (o == PLUS || o == MINUS || o == MUL || o == DIV) {
     
 !
254251                         }
 255252                 }
 256253 
<>257 -        /* it's real; we must make a new node */
  254+        /* its real; we must make a new node */
258255 
 259256         p = block(o, l, r, INT, 0, MKSUE(INT));
 260257 
 261258         actions = opact(p);
 262259 #ifndef BUG1
<>263 -        if (adebug)
  260+        if (adebug)     /* XXX 4.4 */
264261                 printact(p, actions);
 265262 #endif
 266263 
 267264         if( actions&LVAL ){ /* check left descendent */
 268265                 if( notlval(p->n_left) ) {
<>269 -                        uerror( "illegal lvalue operand of assignment operator" );
  266+                        uerror( "lvalue required" );
270267                         }
 271268                 }
 272269 
     
 !
362359                         p->n_sue = MKSUE(FLOAT);
 363360                         break;
 364361 
<>365 -                case DCON:
  362+                case DCON:      /* XXX 4.4 */
366363                         p->n_lval = 0;
 367364                         p->n_rval = 0;
 368365                         p->n_type = DOUBLE;
     
 !
432429                                 p = buildtree( QUEST, l->n_left, buildtree( COLON, ll, lr ) );
 433430                                 break;
 434431 
<>435 -# ifdef ADDROREG
  432+# ifdef ADDROREG        /* XXX 4.4  addroreg */
436433                         case OREG:
 437434                                 /* OREG was built in clocal()
 438435                                  * for an auto or formal parameter
     
 !
453450                         break;
 454451 
 455452                 case LS:
<>456 -                case RS:
  453+                case RS:        /* XXX 4.4 satsen */
457454                         if( l->n_type == CHAR || l->n_type == SHORT )
 458455                                 p->n_type = INT;
 459456                         else if( l->n_type == UCHAR || l->n_type == USHORT )
     
 !
553550         if( actions & CVTO ) p = oconvert(p);
 554551         p = clocal(p);
 555552 
<>556 -# ifndef BUG1
  553+#ifdef PCC_DEBUG
557554         if( bdebug ) fwalk( p, eprint, 0 );
<>558 -# endif
  555+#endif
559556 
 560557         return(p);
 561558 
     
 !
566563 
 567564 void fpe(int);
 568565 void
<>569 -fpe(int a)
  566+fpe(int a)      /* XXX 4.4 */
570567 {
 571568         if (fpe_count < 0)
 572569                 cerror("floating point exception");
 573570         ++fpe_count;
 574571         longjmp(gotfpe, 1);
 575572 }
 576573 
<>577 -/*
  574+/*      * XXX 4.4 comments *
578575  * Rewrite arguments in a function call.
 579576  * Structure arguments are massaged, single
 580577  * precision floating point constants are
     
 !
595592                 p->n_left = buildtree( UNARY AND, p->n_left, NIL );
 596593                 p = clocal(p);
 597594                 }
<>598 -        else if( o == FCON )
  595+        else if( o == FCON )    /* XXX 4.4 */
599596                 p = makety(p, DOUBLE, 0, 0);
 600597         return( p );
 601598 }
 602599 
 603600 /*
 604601  * apply the op o to the lval part of p; if binary, rhs is val
<>605 - * works only on integer constants
606602  */
 607603 int
 608604 conval(NODE *p, int o, NODE *q)
 609605 {
 610606         int i, u;
 611607         CONSZ val;
<>612 -        TWORD utype;
  608+        TWORD utype;    /* XXX 4.4 */
613609 
 614610         val = q->n_lval;
 615611         u = ISUNSIGNED(p->n_type) || ISUNSIGNED(q->n_type);
     
 !
622618         if (p->n_sp != NULL && o != PLUS && o != MINUS)
 623619                 return(0);
 624620 
<> 621+                /* XXX 4.4 följande stycke */
625622         /* usual type conversions -- handle casts of constants */
 626623 #define ISLONG(t)       ((t) == LONG || (t) == ULONG)
 627624 #define ISLONGLONG(t)   ((t) == LONGLONG || (t) == ULONGLONG)
     
 !
653650                 break;
 654651         case DIV:
 655652                 if( val == 0 ) uerror( "division by 0" );
<>656 -                else if ( u ) p->n_lval = (unsigned) p->n_lval / val;
  653+                else if ( u ) p->n_lval = (unsigned) p->n_lval / val;   /* XXX 4.4 */
657654                 else p->n_lval /= val;
 658655                 break;
 659656         case MOD:
 660657                 if( val == 0 ) uerror( "division by 0" );
<>661 -                else if ( u ) p->n_lval = (unsigned) p->n_lval % val;
  658+                else if ( u ) p->n_lval = (unsigned) p->n_lval % val;   /* XXX 4.4 */
662659                 else p->n_lval %= val;
 663660                 break;
 664661         case AND:
     
 !
676673                 break;
 677674         case RS:
 678675                 i = val;
<>679 -                if ( u ) p->n_lval = (unsigned) p->n_lval >> i;
  676+                if ( u ) p->n_lval = (unsigned) p->n_lval >> i/* XXX 4.4 */
680677                 else p->n_lval = p->n_lval >> i;
 681678                 break;
 682679 
     
 !
748745         if (t1==ENUMTY || t2==ENUMTY) {
 749746                 /* rob pike says this is obnoxious...
 750747                 if( logop( p->n_op ) && p->n_op != EQ && p->n_op != NE )
<>751 -                        werror( "comparison of enums" ); */
  748+                        werror( "comparison of enums" ); */     /* XXX 4.4 */
752749                 if (t1==ENUMTY && t2==ENUMTY) {
 753750                         if (p->n_left->n_sue!=p->n_right->n_sue)
 754751                                 werror("enumeration type clash, "
<>755 -                                    "operator %s", opst[p->n_op]);
  752+                                    "operator %s", opst[p->n_op]);      /* XXX 4.4 */
756753                         return;
 757754                 }
 758755                 if (t1 == ENUMTY)
     
 !
764761         ref1 = ISPTR(t1) || ISARY(t1);
 765762         ref2 = ISPTR(t2) || ISARY(t2);
 766763 
<>767 -        if (ref1 ^ ref2) {
  764+        if (ref1 ^ ref2) {      /* XXX 4.4 */
768765                 if (ref1)
 769766                         q = p->n_right;
 770767                 else
 771768                         q = p->n_left;
 772769                 if (q->n_op != ICON || q->n_lval != 0)
 773770                         werror("illegal combination of pointer "
 774771                             "and integer, op %s", opst[p->n_op]);
<>775 -        } else if (ref1) {
  772+        } else if (ref1) {      /* XXX 4.4 */
776773                 if (t1 == t2) {
 777774                         if (p->n_left->n_sue != p->n_right->n_sue) {
 778775                                 werror("illegal structure pointer combination");
     
 !
802799                                                 break;
 803800                                 t1 = DECREF(t1);
 804801                         }
<>805 -                } else if (t1 != INCREF(UNDEF) && t2 != INCREF(UNDEF))
  802+                } else if (t1 != INCREF(UNDEF) && t2 != INCREF(UNDEF))  /* XXX 4.4 */
806803                         werror("illegal pointer combination");
 807804         }
 808805 }
     
 !
813810         struct suedef *sue;
 814811         union dimfun *d;
 815812         TWORD t;
<>816 -        int dsc, align;
  813+        int dsc, align/* XXX 4.4 */
817814         OFFSZ off;
 818815         register struct symtab *q;
 819816 
     
 !
842839         dsc = q->sclass;
 843840 
 844841         if (dsc & FIELD) {  /* normalize offset */
<>845 -                align = ALINT;
  842+                align = ALINT;  /* XXX 4.4 */
846843                 sue = MKSUE(INT);
<>847 -                off = (off/align)*align;
  844+                off = (off/align)*align;        /* XXX 4.4 */
848845         }
 849846         if (off != 0)
 850847                 p = clocal(block(PLUS, p, offcon(off, t, d, sue), t, d, sue));
     
 !
876873                 p = p->n_left;
 877874                 goto again;
 878875 
<>879 -        case UNARY MUL:
  876+        case UNARY MUL/* XXX 4.4 */
880877                 /* fix the &(a=b) bug, given that a and b are structures */
 881878                 if( p->n_left->n_op == STASG ) return( 1 );
 882879                 /* and the f().a bug, given that f returns a structure */
     
 !
957954         return(p);
 958955 }
 959956 
<>960 -#ifndef econvert
  957+#ifndef econvert        /* XXX 4.4 */
961958 void
 962959 econvert( p ) register NODE *p; {
 963960 
     
 !
11291126 
 11301127         t1 = p->n_left->n_type;
 11311128         t2 = p->n_right->n_type;
<>1132 -        if( (t1==UNDEF || t2==UNDEF) && o!=CAST )
  1129+        if( (t1==UNDEF || t2==UNDEF) && o!=CAST )       /* XXX 4.4 */
11331130                 uerror("void type illegal in expression");
 11341131 
 11351132         u = 0;
     
 !
11451142         if( ( t1 == CHAR || t1 == SHORT ) && o!= RETURN ) t1 = INT;
 11461143         if( t2 == CHAR || t2 == SHORT ) t2 = INT;
 11471144 
<>1148 -#ifdef SPRECC
  1145+#ifdef SPRECC   /* XXX 4.4 */
11491146         if( t1 == DOUBLE || t2 == DOUBLE )
 11501147                 t = DOUBLE;
 11511148         else if( t1 == FLOAT || t2 == FLOAT )
     
 !
11611158         else
 11621159                 t = INT;
 11631160 
<>1164 -        if( o == ASSIGN || o == CAST || o == RETURN ) {
  1161+        if( o == ASSIGN || o == CAST || o == RETURN ) { /* XXX 4.4 */
11651162                 tu = p->n_left->n_type;
 11661163                 t = t1;
 11671164         } else {
     
 !
11731170            are those involving FLOAT/DOUBLE, and those
 11741171            from LONG to INT and ULONG to UNSIGNED */
 11751172 
<>1176 -        if( (t != t1 || (u && !ISUNSIGNED(p->n_left->n_type))) && ! asgop(o) )
 1177 -                p->n_left = makety( p->n_left, tu, 0, MKSUE(tu));
  1173+        if( (t != t1 || (u && !ISUNSIGNED(p->n_left->n_type))) && ! asgop(o) )  /* XXX 4.4 */
  1174+                p->n_left = makety( p->n_left, tu, 0, MKSUE(tu));       /* XXX 4.4 */
11781175 
<>1179 -        if( t != t2 || (u && !ISUNSIGNED(p->n_right->n_type)) || o==CAST) {
 1180 -                if ( tu == ENUMTY ) {/* always asgop */
 1181 -                        p->n_right = makety( p->n_right, INT, 0, MKSUE(INT));
 1182 -                        p->n_right->n_type = tu;
 1183 -                        p->n_right->n_df = p->n_left->n_df;
 1184 -                        p->n_right->n_sue = p->n_left->n_sue;
 1185 -                        }
 1186 -                else
 1187 -                        p->n_right = makety( p->n_right, tu, 0, MKSUE(tu));
  1176+        if( t != t2 || (u && !ISUNSIGNED(p->n_right->n_type)) || o==CAST) {     /* XXX 4.4 */
  1177+                if ( tu == ENUMTY ) {/* always asgop */ /* XXX 4.4 */
  1178+                        p->n_right = makety( p->n_right, INT, 0, MKSUE(INT));   /* XXX 4.4 */
  1179+                        p->n_right->n_type = tu;        /* XXX 4.4 */
  1180+                        p->n_right->n_df = p->n_left->n_df;     /* XXX 4.4 */
  1181+                        p->n_right->n_sue = p->n_left->n_sue;   /* XXX 4.4 */
  1182+                        }       /* XXX 4.4 */
  1183+                else    /* XXX 4.4 */
  1184+                        p->n_right = makety( p->n_right, tu, 0, MKSUE(tu));     /* XXX 4.4 */
11881185         }
 11891186 
 11901187         if( asgop(o) ){
     
 !
12241221                 }
 12251222 
 12261223         if( p->n_op == ICON ){
<>1227 -                if (t == DOUBLE) {
  1224+                if (t == DOUBLE) {      /* XXX 4.4 */
12281225                         p->n_op = DCON;
 12291226                         if (ISUNSIGNED(p->n_type))
 12301227                                 p->n_dcon = (U_CONSZ) p->n_lval;
     
 !
12341231                         p->n_sue = MKSUE(t);
 12351232                         return (clocal(p));
 12361233                 }
<>1237 -                if (t == FLOAT) {
  1234+                if (t == FLOAT) {       /* XXX 4.4 */
12381235                         p->n_op = FCON;
 12391236                         if( ISUNSIGNED(p->n_type) ){
 12401237                                 p->n_fcon = (U_CONSZ) p->n_lval;
     
 !
12481245                         return( clocal(p) );
 12491246                         }
 12501247                 }
<>1251 -        else if (p->n_op == FCON && t == DOUBLE) {
  1248+        else if (p->n_op == FCON && t == DOUBLE) {      /* XXX 4.4 */
12521249                 double db;
 12531250 
<>1254 -                p->n_op = DCON;
 1255 -                db = p->n_fcon;
 1256 -                p->n_dcon = db;
 1257 -                p->n_type = t;
 1258 -                p->n_sue = MKSUE(t);
 1259 -                return (clocal(p));
 1260 -        } else if (p->n_op == DCON && t == FLOAT) {
 1261 -                float fl;
 1262 -
 1263 -                p->n_op = FCON;
 1264 -                fl = p->n_dcon;
  1251+                p->n_op = DCON/* XXX 4.4 */
  1252+                db = p->n_fcon/* XXX 4.4 */
  1253+                p->n_dcon = db/* XXX 4.4 */
  1254+                p->n_type = t;  /* XXX 4.4 */
  1255+                p->n_sue = MKSUE(t);    /* XXX 4.4 */
  1256+                return (clocal(p));     /* XXX 4.4 */
  1257+        } else if (p->n_op == DCON && t == FLOAT) {     /* XXX 4.4 */
  1258+                float fl;       /* XXX 4.4 */
  1259+        /* XXX 4.4 */
  1260+                p->n_op = FCON/* XXX 4.4 */
  1261+                fl = p->n_dcon/* XXX 4.4 */
12651262 #ifdef notdef
 12661263                 if (fl != p->n_dcon)
 12671264                         werror("float conversion loses precision");
     
 !
12721269                 return (clocal(p));
 12731270         }
 12741271 
<>1275 -        return( clocal( block( SCONV, p, NIL, t, d, sue)));
  1272+        return( clocal( block( SCONV, p, NIL, t, d, sue)));     /* XXX 4.4 */
12761273 
 12771274         }
 12781275 
     
 !
13451342 # define MPTR 010       /* pointer */
 13461343 # define MPTI 020       /* pointer or integer */
 13471344 # define MENU 040       /* enumeration variable or member */
<>1348 -# define MVOID 0100000  /* void type */
  1345+# define MVOID 0100000  /* void type */ /* XXX 4.4 */
13491346 
 13501347 int
<>1351 -opact(NODE *p)
  1348+opact(NODE *p)  /* XXX 4.4 hela opact mixtrad med */
<_13521349 {
 13531350         int mt12, mt1, mt2, o;
 13541351 
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-21 21:52 +0100