From d374ac2e2fc9cfdf28f6f2f1bf95874cc45b458d Mon Sep 17 00:00:00 2001 From: pault Date: Sun, 18 Feb 2007 19:52:16 +0000 Subject: [PATCH] 2007-02-18 Roger Sayle Paul Thomas PR fortran/30400 * match.c (match_forall_iterator): Use gfc_match_expr instead of gfc_match_variable to match the iterator variable. Return MATCH_NO if not a variable. Remove the reset of the symbol's flavor in cleanup. 2007-02-18 Roger Sayle * gfortran.dg/forall_10.f90: New test case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122102 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 9 +++++++++ gcc/fortran/match.c | 16 +++++++--------- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gfortran.dg/forall_10.f90 | 25 +++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/forall_10.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 02ba34f..43c10ee 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2007-02-18 Roger Sayle + Paul Thomas + + PR fortran/30400 + * match.c (match_forall_iterator): Use gfc_match_expr instead + of gfc_match_variable to match the iterator variable. Return + MATCH_NO if not a variable. Remove the reset of the symbol's + flavor in cleanup. + 2007-02-16 Tobias Burnus PR fortran/30793 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 941e625..bf78911 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -3358,7 +3358,10 @@ gfc_free_forall_iterator (gfc_forall_iterator *iter) /* Match an iterator as part of a FORALL statement. The format is: - = :[:][, ] */ + = :[:] + + On MATCH_NO, the caller tests for the possibility that there is a + scalar mask expression. */ static match match_forall_iterator (gfc_forall_iterator **result) @@ -3370,11 +3373,12 @@ match_forall_iterator (gfc_forall_iterator **result) where = gfc_current_locus; iter = gfc_getmem (sizeof (gfc_forall_iterator)); - m = gfc_match_variable (&iter->var, 0); + m = gfc_match_expr (&iter->var); if (m != MATCH_YES) goto cleanup; - if (gfc_match_char ('=') != MATCH_YES) + if (gfc_match_char ('=') != MATCH_YES + || iter->var->expr_type != EXPR_VARIABLE) { m = MATCH_NO; goto cleanup; @@ -3415,12 +3419,6 @@ syntax: m = MATCH_ERROR; cleanup: - /* Make sure that potential internal function references in the - mask do not get messed up. */ - if (iter->var - && iter->var->expr_type == EXPR_VARIABLE - && iter->var->symtree->n.sym->refs == 1) - iter->var->symtree->n.sym->attr.flavor = FL_UNKNOWN; gfc_current_locus = where; gfc_free_forall_iterator (iter); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 13745a0..5870a68 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2007-02-18 Roger Sayle + + * gfortran.dg/forall_10.f90: New test case. + 2007-02-18 Eric Botcazou * gnat.dg/tail_call_p.ads, tail_call_p.adb, tail_call.adb: New test. diff --git a/gcc/testsuite/gfortran.dg/forall_10.f90 b/gcc/testsuite/gfortran.dg/forall_10.f90 new file mode 100644 index 0000000..1b16840 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/forall_10.f90 @@ -0,0 +1,25 @@ +! { dg-do run } +! { dg-options "-O" } +! Tests the fix for PR30400, in which the use of ANY in the +! FORALL mask was rejected. +! +! Contributed by Dominique d'Humieres +! +program pr30400_1 + real, dimension (5, 5, 5, 5) :: a + + a (:, :, :, :) = 4 + a (:, 2, :, 4) = 10 + a (:, 2, :, 1) = 0 + + forall (i = 1:5, j = 1:5, k = 1:5, any (a (i, j, k, :) .gt. 6)) + forall (l = 1:5, any (a (:, :, :, l) .lt. 2)) + a (i, j, k, l) = i - j + k - l + end forall + end forall + if (sum (a) .ne. 2625.0) call abort () + + ! Check that the fix has not broken the treatment of the '==' + forall (i = 1:5, i == 3) a(i, i, i, i) = -5 + if (sum (a) .ne. 2616.0) call abort () +end -- 2.7.4