[Patch, fortran] PR22038, PR25072 and PR28119 - things broken in forall statements
Paul Thomas
paulthomas2@wanadoo.fr
Thu Jun 22 15:51:00 GMT 2006
:ADDPATCH fortran:
The point of this contribution from Joost VandeVondele
INTEGER :: I, A(10)
FORALL (I = 1:10, T (I)) A(I) = I
CONTAINS
LOGICAL FUNCTION T (I)
INTEGER :: I
T = (MOD (I, 2) == 0)
END FUNCTION T
END
was that the function referenced in the forall mask should be pure.
However, gfortran responds with
Internal Error at (1):
free_expr0(): Bad expr type
whether or not T is pure!
This turns out to be due to the attempt to match the mask to a forall
iterator. Since T is internal and not referenced, match_variable
fixes it up as having flavor FL_VARIABLE, which causes the mask not
to match. Two regtestable fixes were developed in match_variable
and gfc_match_rvalue but I decided that slightly ad-hoc fixes in these
functions for a very specific problem was not a good idea. Instead,
the proposed patch is to the cleanup in match_forall_iterator. If a
symtree is created for the iterator variable, which is detected by
the expression pointing to the symtree and the symbol having only 1
reference, this is set to FL_UNKNOWN, so that the matching of the
mask works.
Having fixed this, we find that the original problem is still
present; ie. we need to signal an error if T is not pure. This is
done in resolve.c by a small extension to the flagging system for
non-pure references in the forall-block.
I have not touched subroutine references since I do not think that
non-PURE subroutines can be referenced from the mask expression
(If contained in PURE functions, an error is signalled for a
non-PURE reference from within a PURE procedure.)
Finally,
FORALL (I = 1:10, T (I)) A(I) = I ; any_stmt_at_all
generated
1
Internal Error at (1):
free_expr0(): Bad expr type
and this was caused by an extraneous gfc_match_eos. This function
is already carried out by the match to the assignment. Removing
this cures the problem.
Regtested on FC5/Athlon - OK for trunk and 4.1?
Paul
2006-06-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/22038
* match.c (match_forall_iterator): Mark new variables as
FL_UNKNOWN if the match fails.
PR fortran/28119
* match.c (gfc_match_forall): Remove extraneous call to
gfc_match_eos.
PR fortran/25072
* resolve.c (resolve_code, resolve_function): Rework
forall_flag scheme so that it is set and has a value of
2, when the code->expr (ie. the forall mask) is resolved.
This is used to change "block" to "mask" in the non-PURE
error message.
2006-06-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/22038
PR fortran/28119
* gfortran.dg/forall_4.f90: New test.
PR fortran/25072
* gfortran.dg/forall_5.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr25072_2.diff
Type: text/x-patch
Size: 2052 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060622/15c61cad/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: forall_4.f90
Type: text/x-fortran
Size: 1703 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060622/15c61cad/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: forall_5.f90
Type: text/x-fortran
Size: 967 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060622/15c61cad/attachment-0002.bin>
More information about the Gcc-patches
mailing list