Paul Thomas <pault@gcc.gnu.org>
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 <roger@eyesopen.com>
* 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
+2007-02-18 Roger Sayle <roger@eyesopen.com>
+ Paul Thomas <pault@gcc.gnu.org>
+
+ 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 <burnus@net-b.de>
PR fortran/30793
/* Match an iterator as part of a FORALL statement. The format is:
- <var> = <start>:<end>[:<stride>][, <scalar mask>] */
+ <var> = <start>:<end>[:<stride>]
+
+ 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)
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;
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);
+2007-02-18 Roger Sayle <roger@eyesopen.com>
+
+ * gfortran.dg/forall_10.f90: New test case.
+
2007-02-18 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/tail_call_p.ads, tail_call_p.adb, tail_call.adb: New test.
--- /dev/null
+! { 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 <dominiq@lps.ens.fr>
+!
+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