This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch] PR 35940 Array BACK ignored in INDEX intrinsic when other args scalar
- From: Bud Davis <bdavis9659 at sbcglobal dot net>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 29 Apr 2008 17:51:47 -0700 (PDT)
- Subject: [patch] PR 35940 Array BACK ignored in INDEX intrinsic when other args scalar
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=sbcglobal.net; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=LGODJ+V2fBVP6vxcUK5/8tz/4ekHXbr0B0rgqnP/gTZKmBqSAAjqpOFQw61GMOuWTa050c36XvGrMqA8jPIaALhv7ZaQVziBOwzVdIjq+x7je5GI/BtktjaalMfvBbNCUX2/kQ90yhk3UFvqje7BF8nGVEnd6kfSQsrH/mz5g6w=;
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.