This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] PR 35940 Array BACK ignored in INDEX intrinsic when other args scalar


The expression was being simplified when it should not have been.  Corrected by checking for a
constant argument in do_simplify.

The below test case fails prior to application of the patch and passes after.  The test case is
the submitters code, with a bit of editing.

Tested i686/gnu linux with no new regressions.

--bud davis


Index: gcc/gcc/fortran/simplify.c
===================================================================
--- gcc/gcc/fortran/simplify.c  (revision 134801)
+++ gcc/gcc/fortran/simplify.c  (working copy)
@@ -1570,7 +1570,8 @@
   int back, len, lensub;
   int i, j, k, count, index = 0, start;
 
-  if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT)
+  if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT 
+      || ( b != NULL && b->expr_type !=  EXPR_CONSTANT))
     return NULL;
 
   if (b != NULL && b->value.logical != 0)
 
      program FA1031
      implicit none
      integer I
      INTEGER IDA1(10)
      LOGICAL GDA1(10)
      INTEGER RSLT(10)
      DATA RSLT /4,1,4,1,4,1,4,1,4,1/
      IDA1   = 0
      gda1 = (/ (i/2*2 .ne. I, i=1,10) /)

      IDA1 = INDEX ( 'DEFDEF' , 'DEF', GDA1 )    !fails
      do I = 1, 10
         if (IDA1(i).NE.RSLT(i)) call abort
      end do
      IDA1 = INDEX ( (/ ('DEFDEF',i=1,10) /) , 'DEF', GDA1 )    !works
      do I = 1, 10
         if (IDA1(i).NE.RSLT(i)) call abort
      end do

      END
2008-04-30  Bud Davis <bdavis9659@sbcglobal.net>
            
            PR35940/Fortran
            * simplify.c (gfc_simplify_index): Check for direction
            argument being a constant.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]