[PATCH,gfortran] Fix PR 16222
Paul Brook
paul@codesourcery.com
Sun Dec 12 20:27:00 GMT 2004
> I've introduced the two defines INTEGER_ONLY and REAL_OK and
> updated gfc_resolve_iterator to permit REAL iterators for
> DO loop variables. Other uses of gfc_resolve_iterator use
> INTEGER_ONLY.
I turned these into a simple boolean.
I also pulled the checks common to all elements of the iterator out into a
common routine.
> > Are you deliberately allowing a mixture of integer and real types?
>
> This has been fixed in gfc_resolve_iterator where I use gfc_convert_type
> to force start, end, and step to the type and kind type parameter of
> the DO loop variable.
Ok. I changed to comment to reflect that this we ensure, not a prerequisite.
> > This seems like it deserves at least a -Wsuprising/-Wconversion warning.
>
> I did not put in these options. If you really want them, I'll do it.
Ok.
> > You should also update the comment(s) in gfc_trans_do. Remove the TODO,
> > and mention how we handle this case - make the conversion explicit in the
> > pseudocode.
>
> I removed the TODO, but did not add a comment about the conversion
> because the conversion is actually done resolve.c.
>
> > > /* Decrement the loop count. */
> > > + if (TREE_CODE (type) == INTEGER_TYPE)
> > > tmp = build2 (MINUS_EXPR, type, count, gfc_index_one_node);
> > > + else
> > > + tmp = build2 (MINUS_EXPR, gfc_array_index_type, count,
> >
> > gfc_index_one_node);
> >
> > > gfc_add_modify_expr (&body, count, tmp);
> >
> > The existing code is wrong, and your code is overly complicated. Try:
> >
> > tree count_one = build_int_cst (TREE_TYPE (count), 1);
> > ...
> > tmp = build2 (MINUS_EXPR, TREE_TYPE (count), count, count_one);
>
> I don't follow you here. This is probably due to my lack of
> understanding of the tree-ssa stuff and the backend. Can you
> look at what I did and see if it's accept.
What you did was ok, except that forcing the count variable to
index_integer_kind for integer indices is wrong. I changed the code to use
the type kind of the loop variable for integer loops, and index_integer_kind
for real loops. I'm not sure if it's right for real iterators either, but
it's a relatively safe choice.
Tested on i686-linux.
Applied as attached.
Paul
2004-12-12 Steven G. Kargl <kargls@comcast.net>
Paul Brook <paul@codesourcery.com>
PR fortran/16222
* resolve.c (gfc_resolve_iterator_expr): New function.
(gfc_resolve_iterator): Use it. Add real_ok argument. Convert
start, end and stride to correct type.
(resolve_code): Pass extra argument.
* array.c (resolve_array_list): Pass extra argument.
* gfortran.h (gfc_resolve): Add prototype.
* trans-stmt.c (gfc_trans_do): Remove redundant type conversions.
Handle real type iterators.
testsuite/
* gfortran.dg/real_do_1.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch
Type: text/x-diff
Size: 12365 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20041212/63bf8f3d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: real_do_1.f90
Type: text/x-csrc
Size: 399 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20041212/63bf8f3d/attachment-0001.bin>
More information about the Fortran
mailing list