cvsuser     04/01/15 07:33:21

  Modified:    imcc     Tag: imcc1final pcc.c
  Log:
  Fix off by 1 error pointed out by Leo.
  Change REGSET_MAX to 4 to use < instead of <= in for loops.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.39.2.2  +9 -9      parrot/imcc/pcc.c
  
  Index: pcc.c
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/pcc.c,v
  retrieving revision 1.39.2.1
  retrieving revision 1.39.2.2
  diff -u -w -r1.39.2.1 -r1.39.2.2
  --- pcc.c     15 Jan 2004 07:11:10 -0000      1.39.2.1
  +++ pcc.c     15 Jan 2004 15:33:21 -0000      1.39.2.2
  @@ -49,7 +49,7 @@
   #define REGSET_S 1
   #define REGSET_P 2
   #define REGSET_N 3
  -#define REGSET_MAX 3
  +#define REGSET_MAX 4
   
   static const char regsets[] = "ISPN";
   
  @@ -291,7 +291,7 @@
   
       }
       for (proto = ps; proto <= pe; ++proto) {
  -     for (i = 0; i <= REGSET_MAX; i++)
  +     for (i = 0; i < REGSET_MAX; i++)
            next[i] = FIRST_PARAM_REG;
        /* insert params */
        nargs = sub->pcc_sub->nargs;
  @@ -299,7 +299,7 @@
            arg = sub->pcc_sub->args[i];
            if (proto == 1 ||
                    (arg->set == 'P' && next[REGSET_P] < 16)) {
  -             for (set = 0; set <= REGSET_MAX; set++) {
  +             for (set = 0; set < REGSET_MAX; set++) {
                    if (arg->set == regsets[set]) {
                        if (next[set] > LAST_PARAM_REG) {
   #if IMC_TRACE
  @@ -458,7 +458,7 @@
                       /* goon */
                   case VTCONST:
   lazy:
  -                    for (set = 0; set <= REGSET_MAX; set++) {
  +                    for (set = 0; set < REGSET_MAX; set++) {
                           if (arg->set == regsets[set]) {
                               if (next[set] > LAST_PARAM_REG)
                                   goto overflow;
  @@ -478,7 +478,7 @@
                       break;
                   default:
                       if (arg->type & VTREGISTER) {
  -                        for (set = 0; set <= REGSET_MAX; set++)
  +                        for (set = 0; set < REGSET_MAX; set++)
                               if (arg->set == regsets[set]) {
                                   arg->reg->want_regno = next[set];
                                   sub->pcc_sub->ret[i]->used = arg->reg;
  @@ -518,7 +518,7 @@
       ins = set_I_const(interpreter, unit, ins, 0, sub->pcc_sub->prototyped);
   
       /* Setup argument counts */
  -    for (i = 0; i <= REGSET_MAX; i++)
  +    for (i = 0; i < REGSET_MAX; i++)
           ins = set_I_const(interpreter, unit, ins, i + 1, next[i] - 5);
   
       /*
  @@ -823,7 +823,7 @@
       tail_call = check_tail_call(interp, unit, ins);
       if (tail_call)
           debug(interp, DEBUG_OPT1, "found tail call %I \n", ins);
  -    for (i = 0; i <= REGSET_MAX; i++)
  +    for (i = 0; i < REGSET_MAX; i++)
           next[i] = FIRST_PARAM_REG;
       call_ins = ins;
       sub = ins->r[0];
  @@ -880,7 +880,7 @@
                   case VT_CONSTP:
                   case VTCONST:
   lazy:
  -                    for (set = 0; set <= REGSET_MAX; set++) {
  +                    for (set = 0; set < REGSET_MAX; set++) {
                           if (arg_reg->set == regsets[set]) {
                               if (arg_reg->type != VTCONST &&
                                       arg_reg->color == next[set]) {
  @@ -904,7 +904,7 @@
                   default:
                       if (arg->type & VTREGISTER) {
                           /* TODO for now just emit a register move */
  -                        for (set = 0; set <= REGSET_MAX; set++)
  +                        for (set = 0; set < REGSET_MAX; set++)
                               if (arg->set == regsets[set]) {
                                   if (set == 2 &&
                                           (flatten ||
  
  
  

Reply via email to