From: Bud Davis Date: Fri, 2 May 2008 04:05:12 +0000 (+0000) Subject: PR fortran/PR35940 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=00113de86ecca65a1ecfa40f279ab907ac202db8;p=gcc.git PR fortran/PR35940 2008-05-01 Bud Davis PR fortran/PR35940 * gfortran.dg/index.f90: New test. 2008-05-01 Bud Davis PR35940/Fortran * simplify.c (gfc_simplify_index): Check for direction argument being a constant. From-SVN: r134879 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f9ae961007a..a0755f88124 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2008-05-01 Bud Davis + + PR35940/Fortran + * simplify.c (gfc_simplify_index): Check for direction argument + being a constant. + 2008-05-01 Janus Weil * gfortran.h (struct gfc_symbol): Moving "interface" member to diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 62c1cd45aec..cde4770a1ec 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -1570,7 +1570,8 @@ gfc_simplify_index (gfc_expr *x, gfc_expr *y, gfc_expr *b, gfc_expr *kind) 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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c4ef1364b47..82d3a4da6cc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-05-01 Bud Davis + + PR fortran/PR35940 + * gfortran.dg/index.f90: New test. + 2008-05-01 Simon Baldwin * testsuite/gcc.dg/Warray-bounds.c: Updated for frontend warnings, diff --git a/gcc/testsuite/gfortran.dg/index.f90 b/gcc/testsuite/gfortran.dg/index.f90 new file mode 100644 index 00000000000..58cd25c701e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/index.f90 @@ -0,0 +1,22 @@ +! { dg-do run } +! pr35940 + 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