Patch fixing a typo in genautomata.c

Vladimir Makarov vmakarov@redhat.com
Mon Apr 14 15:50:00 GMT 2003


  The following patch fixes a typo which might result in genautomata
crash.

The patch has been tested on regression tests and bootstrap for x86
and ia64.  I did not find a degradation.  I've commited the patch into
the main trunk.

Vlad

2003-04-14  Vladimir Makarov  <vmakarov@redhat.com>

        * genautomata.c (output_translate_vect): Fix a typo in loop
        condition.
-------------- next part --------------
Index: genautomata.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genautomata.c,v
retrieving revision 1.10
diff -c -p -r1.10 genautomata.c
*** genautomata.c	7 May 2002 19:07:46 -0000	1.10
--- genautomata.c	14 May 2002 16:13:59 -0000
*************** transform_2 (regexp)
*** 4637,4643 ****
  
  /* The function makes transformations
     ...,A|B|...,C,... -> (...,A,C,...)|(...,B,C,...)|...
!    ...+(A|B|...)+C+... -> (...+A+C+...)|(...+B+C+...)|...  */
  static regexp_t
  transform_3 (regexp)
       regexp_t regexp;
--- 4637,4644 ----
  
  /* The function makes transformations
     ...,A|B|...,C,... -> (...,A,C,...)|(...,B,C,...)|...
!    ...+(A|B|...)+C+... -> (...+A+C+...)|(...+B+C+...)|...
!    ...+(A,B,...)+C+... -> (...+A+C+...),B,...  */
  static regexp_t
  transform_3 (regexp)
       regexp_t regexp;
*************** transform_3 (regexp)
*** 4693,4700 ****
      }
    else if (regexp->mode == rm_allof)
      {
!       regexp_t oneof;
!       int oneof_index;
        regexp_t result;
        regexp_t allof;
        int i, j;
--- 4694,4701 ----
      }
    else if (regexp->mode == rm_allof)
      {
!       regexp_t oneof, seq;
!       int oneof_index, seq_index;
        regexp_t result;
        regexp_t allof;
        int i, j;
*************** transform_3 (regexp)
*** 4736,4741 ****
--- 4737,4781 ----
  		  allof->regexp.allof.regexps [j]
  		    = copy_insn_regexp (oneof->regexp.oneof.regexps [i]);
  	    }
+ 	  regexp_transformed_p = 1;
+ 	  regexp = result;
+ 	}
+       for (i = 0; i < regexp->regexp.allof.regexps_num; i++)
+ 	if (regexp->regexp.allof.regexps [i]->mode == rm_sequence)
+ 	  {
+ 	    seq_index = i;
+ 	    seq = regexp->regexp.allof.regexps [i];
+ 	    break;
+ 	  }
+       if (i < regexp->regexp.allof.regexps_num)
+ 	{
+ 	  if (seq->regexp.sequence.regexps_num <= 1
+ 	      || regexp->regexp.allof.regexps_num <= 1)
+ 	    abort ();
+ 	  result = create_node (sizeof (struct regexp)
+ 				+ sizeof (regexp_t)
+ 				* (seq->regexp.sequence.regexps_num - 1));
+ 	  result->mode = rm_sequence;
+ 	  result->pos = regexp->pos;
+ 	  result->regexp.sequence.regexps_num
+ 	    = seq->regexp.sequence.regexps_num;
+ 	  allof = create_node (sizeof (struct regexp)
+ 			       + sizeof (regexp_t)
+ 			       * (regexp->regexp.allof.regexps_num - 1));
+ 	  allof->mode = rm_allof;
+ 	  allof->pos = regexp->pos;
+ 	  allof->regexp.allof.regexps_num = regexp->regexp.allof.regexps_num;
+ 	  result->regexp.sequence.regexps [0] = allof;
+ 	  for (j = 0; j < allof->regexp.allof.regexps_num; j++)
+ 	    if (j != seq_index)
+ 	      allof->regexp.allof.regexps [j]
+ 		= copy_insn_regexp (regexp->regexp.allof.regexps [j]);
+ 	    else
+ 	      allof->regexp.allof.regexps [j]
+ 		= copy_insn_regexp (seq->regexp.sequence.regexps [0]);
+ 	  for (i = 1; i < result->regexp.sequence.regexps_num; i++)
+ 	    result->regexp.sequence.regexps [i]
+ 	      = copy_insn_regexp (seq->regexp.sequence.regexps [i]);
  	  regexp_transformed_p = 1;
  	  regexp = result;
  	}


More information about the Gcc-patches mailing list