[BACK]Return to tree.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / xlint / lint1

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/usr.bin/xlint/lint1/tree.c between version 1.54 and 1.54.2.1

version 1.54, 2008/11/16 07:06:37 version 1.54.2.1, 2009/05/13 19:20:13
Line 1010  typeok(op_t op, int arg, tnode_t *ln, tn
Line 1010  typeok(op_t op, int arg, tnode_t *ln, tn
                         if (!isutyp(rt) && rn->tn_val->v_quad < 0) {                          if (!isutyp(rt) && rn->tn_val->v_quad < 0) {
                                 /* negative shift */                                  /* negative shift */
                                 warning(121);                                  warning(121);
                         } else if ((uint64_t)rn->tn_val->v_quad == size(lt)) {                          } else if ((uint64_t)rn->tn_val->v_quad == (uint64_t)size(lt)) {
                                 /* shift equal to size fo object */                                  /* shift equal to size fo object */
                                 warning(267);                                  warning(267);
                         } else if ((uint64_t)rn->tn_val->v_quad > size(lt)) {                          } else if ((uint64_t)rn->tn_val->v_quad > (uint64_t)size(lt)) {
                                 /* shift greater than size of object */                                  /* shift greater than size of object */
                                 warning(122);                                  warning(122);
                         }                          }
Line 1105  typeok(op_t op, int arg, tnode_t *ln, tn
Line 1105  typeok(op_t op, int arg, tnode_t *ln, tn
                 }                  }
   
                 if (rt == PTR && lt == PTR) {                  if (rt == PTR && lt == PTR) {
                           if (eqptrtype(lstp, rstp, 1))
                                   break;
                         if (!eqtype(lstp, rstp, 1, 0, NULL))                          if (!eqtype(lstp, rstp, 1, 0, NULL))
                                 illptrc(mp, ltp, rtp);                                  illptrc(mp, ltp, rtp);
                         break;                          break;
Line 1256  asgntypok(op_t op, int arg, tnode_t *ln,
Line 1258  asgntypok(op_t op, int arg, tnode_t *ln,
         type_t  *ltp, *rtp, *lstp = NULL, *rstp = NULL;          type_t  *ltp, *rtp, *lstp = NULL, *rstp = NULL;
         mod_t   *mp;          mod_t   *mp;
         const   char *lts, *rts;          const   char *lts, *rts;
           char lbuf[128], rbuf[128];
   
         if ((lt = (ltp = ln->tn_type)->t_tspec) == PTR)          if ((lt = (ltp = ln->tn_type)->t_tspec) == PTR)
                 lst = (lstp = ltp->t_subt)->t_tspec;                  lst = (lstp = ltp->t_subt)->t_tspec;
Line 1307  asgntypok(op_t op, int arg, tnode_t *ln,
Line 1310  asgntypok(op_t op, int arg, tnode_t *ln,
                     ((!lstp->t_const && rstp->t_const) ||                      ((!lstp->t_const && rstp->t_const) ||
                      (!lstp->t_volatile && rstp->t_volatile))) {                       (!lstp->t_volatile && rstp->t_volatile))) {
                         /* left side has not all qualifiers of right */                          /* left side has not all qualifiers of right */
                           tyname(lbuf, sizeof(lbuf), lstp);
                           tyname(rbuf, sizeof(rbuf), rstp);
                         switch (op) {                          switch (op) {
                         case INIT:                          case INIT:
                         case RETURN:                          case RETURN:
                                 /* incompatible pointer types */                                  /* incompatible pointer types */
                                 warning(182);                                  warning(182, lbuf, rbuf);
                                 break;                                  break;
                         case FARG:                          case FARG:
                                 /* argument has incompat. ptr. type, arg #%d */                                  /* argument has incompat. ptr. type, arg #%d */
                                 warning(153, arg);                                  warning(153, arg, lbuf, rbuf);
                                 break;                                  break;
                         default:                          default:
                                 /* operands have incompat. ptr. types, op %s */                                  /* operands have incompat. ptr. types, op %s */
                                 warning(128, mp->m_name);                                  warning(128, mp->m_name, lbuf, rbuf);
                                 break;                                  break;
                         }                          }
                 }                  }
Line 1353  asgntypok(op_t op, int arg, tnode_t *ln,
Line 1358  asgntypok(op_t op, int arg, tnode_t *ln,
                         break;                          break;
                 case FARG:                  case FARG:
                         /* argument has incompatible pointer type, arg #%d */                          /* argument has incompatible pointer type, arg #%d */
                         warning(153, arg);                          warning(153, arg, tyname(lbuf, sizeof(lbuf), ltp),
                               tyname(rbuf, sizeof(rbuf), rtp));
                         break;                          break;
                 default:                  default:
                         illptrc(mp, ltp, rtp);                          illptrc(mp, ltp, rtp);
Line 1540  promote(op_t op, int farg, tnode_t *tn)
Line 1546  promote(op_t op, int farg, tnode_t *tn)
 {  {
         tspec_t t;          tspec_t t;
         type_t  *ntp;          type_t  *ntp;
         int     len;          u_int   len;
   
         t = tn->tn_type->t_tspec;          t = tn->tn_type->t_tspec;
   
Line 2019  cvtcon(op_t op, int arg, type_t *tp, val
Line 2025  cvtcon(op_t op, int arg, type_t *tp, val
                         nv->v_ldbl = v->v_ldbl;                          nv->v_ldbl = v->v_ldbl;
                 } else {                  } else {
                         nv->v_quad = (nt == PTR || isutyp(nt)) ?                          nv->v_quad = (nt == PTR || isutyp(nt)) ?
                                 (uint64_t)v->v_ldbl : (int64_t)v->v_ldbl;                                  (int64_t)v->v_ldbl : (int64_t)v->v_ldbl;
                 }                  }
         } else {          } else {
                 if (nt == FLOAT) {                  if (nt == FLOAT) {
Line 2786  fold(tnode_t *tn)
Line 2792  fold(tnode_t *tn)
                         error(139);                          error(139);
                         q = utyp ? UQUAD_MAX : QUAD_MAX;                          q = utyp ? UQUAD_MAX : QUAD_MAX;
                 } else {                  } else {
                         q = utyp ? ul / ur : sl / sr;                          q = utyp ? (int64_t)(ul / ur) : sl / sr;
                 }                  }
                 break;                  break;
         case MOD:          case MOD:
Line 2795  fold(tnode_t *tn)
Line 2801  fold(tnode_t *tn)
                         error(140);                          error(140);
                         q = 0;                          q = 0;
                 } else {                  } else {
                         q = utyp ? ul % ur : sl % sr;                          q = utyp ? (int64_t)(ul % ur) : sl % sr;
                 }                  }
                 break;                  break;
         case PLUS:          case PLUS:
                 q = utyp ? ul + ur : sl + sr;                  q = utyp ? (int64_t)(ul + ur) : sl + sr;
                 if (msb(sl, t, -1)  != 0 && msb(sr, t, -1) != 0) {                  if (msb(sl, t, -1)  != 0 && msb(sr, t, -1) != 0) {
                         if (msb(q, t, -1) == 0)                          if (msb(q, t, -1) == 0)
                                 ovfl = 1;                                  ovfl = 1;
Line 2809  fold(tnode_t *tn)
Line 2815  fold(tnode_t *tn)
                 }                  }
                 break;                  break;
         case MINUS:          case MINUS:
                 q = utyp ? ul - ur : sl - sr;                  q = utyp ? (int64_t)(ul - ur) : sl - sr;
                 if (msb(sl, t, -1) != 0 && msb(sr, t, -1) == 0) {                  if (msb(sl, t, -1) != 0 && msb(sr, t, -1) == 0) {
                         if (msb(q, t, -1) == 0)                          if (msb(q, t, -1) == 0)
                                 ovfl = 1;                                  ovfl = 1;
Line 2819  fold(tnode_t *tn)
Line 2825  fold(tnode_t *tn)
                 }                  }
                 break;                  break;
         case SHL:          case SHL:
                 q = utyp ? ul << sr : sl << sr;                  q = utyp ? (int64_t)(ul << sr) : sl << sr;
                 break;                  break;
         case SHR:          case SHR:
                 /*                  /*
Line 2848  fold(tnode_t *tn)
Line 2854  fold(tnode_t *tn)
                 q = utyp ? ul != ur : sl != sr;                  q = utyp ? ul != ur : sl != sr;
                 break;                  break;
         case AND:          case AND:
                 q = utyp ? ul & ur : sl & sr;                  q = utyp ? (int64_t)(ul & ur) : sl & sr;
                 break;                  break;
         case XOR:          case XOR:
                 q = utyp ? ul ^ ur : sl ^ sr;                  q = utyp ? (int64_t)(ul ^ ur) : sl ^ sr;
                 break;                  break;
         case OR:          case OR:
                 q = utyp ? ul | ur : sl | sr;                  q = utyp ? (int64_t)(ul | ur) : sl | sr;
                 break;                  break;
         default:          default:
                 LERROR("fold()");                  LERROR("fold()");
         }          }
   
         /* XXX does not work for quads. */          /* XXX does not work for quads. */
         if (ovfl || ((q | mask) != ~(uint64_t)0 && (q & ~mask) != 0)) {          if (ovfl || ((uint64_t)(q | mask) != ~(uint64_t)0 &&
               (q & ~mask) != 0)) {
                 if (hflag)                  if (hflag)
                         /* integer overflow detected, op %s */                          /* integer overflow detected, op %s */
                         warning(141, modtab[tn->tn_op].m_name);                          warning(141, modtab[tn->tn_op].m_name);
Line 3091  bldszof(type_t *tp)
Line 3098  bldszof(type_t *tp)
 }  }
   
 /*  /*
    */
   tnode_t *
   bldalof(type_t *tp)
   {
           tspec_t st;
   
           switch (tp->t_tspec) {
           case ARRAY:
                   break;
   
           case FUNC:
                   /* cannot take align of function */
                   error(144);
                   return 0;
   
           case STRUCT:
           case UNION:
                   if (incompl(tp)) {
                           /* cannot take align of incomplete type */
                           error(143);
                           return 0;
                   }
                   break;
           case ENUM:
                   break;
           default:
                   if (tp->t_isfield) {
                           /* cannot take align of bit-field */
                           error(145);
                           return 0;
                   }
                   if (tp->t_tspec == VOID) {
                           /* cannot take alignsize of void */
                           error(146);
                           return 0;
                   }
                   break;
           }
   
   #if SIZEOF_IS_ULONG
           st = ULONG;
   #else
           st = UINT;
   #endif
   
           return getinode(st, (int64_t)getbound(tp));
   }
   
   /*
  * Type casts.   * Type casts.
  */   */
 tnode_t *  tnode_t *
Line 3737  chkaidx(tnode_t *tn, int amper)
Line 3793  chkaidx(tnode_t *tn, int amper)
         if (!isutyp(rn->tn_type->t_tspec) && con < 0) {          if (!isutyp(rn->tn_type->t_tspec) && con < 0) {
                 /* array subscript cannot be negative: %ld */                  /* array subscript cannot be negative: %ld */
                 warning(167, (long)con);                  warning(167, (long)con);
         } else if (dim > 0 && (uint64_t)con >= dim) {          } else if (dim > 0 && (uint64_t)con >= (uint64_t)dim) {
                 /* array subscript cannot be > %d: %ld */                  /* array subscript cannot be > %d: %ld */
                 warning(168, dim - 1, (long)con);                  warning(168, dim - 1, (long)con);
         }          }

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.54.2.1

CVSweb <webmaster@jp.NetBSD.org>