This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fold VIEW_CONVERT_EXPR <type, STRING_CST> generated by Fortran FE a lot (PR target/35366)
- From: "Paul Richard Thomas" <paul dot richard dot thomas at gmail dot com>
- To: "Tobias Schlüter" <Tobias dot Schlueter at physik dot uni-muenchen dot de>
- Cc: "Jakub Jelinek" <jakub at redhat dot com>, gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org, "Steve Kargl" <sgk at troutmask dot apl dot washington dot edu>, "Feng Wang" <wf_cs at yahoo dot com>
- Date: Tue, 11 Nov 2008 17:21:29 +0100
- Subject: Re: [PATCH] Fold VIEW_CONVERT_EXPR <type, STRING_CST> generated by Fortran FE a lot (PR target/35366)
- References: <20081111131749.GZ3572@tyan-ft48-01.lab.bos.redhat.com> <4919A8A4.8000001@physik.uni-muenchen.de>
Tobi and Jakub,
> They are not standard Fortran. Using Hollerith constants this way was the
> way of encoding strings before there was a Character type in Fortran, so the
> current behavior is intentional. Whether there actually is code that uses
> logicals to encode strings, I can't tell. I CCed Feng Wang who added the
> original Hollerith support, and Steve who last modified the testcase.
I am not so sure about that in the case of transfer_simplify_4.f90 -
we have already had serious amounts of correspondence about it as
witnessed in PR33759. What the standard says is:
>
13.14.110 TRANSFER (SOURCE, MOLD [, SIZE])
Description. Returns a result with a physical representation identical
to that of SOURCE but interpreted with the type and type parameters of
MOLD.
Class. Transformational function.
Arguments.
SOURCE may be of any type and may be scalar or array valued.
MOLD may be of any type and may be scalar or array valued.
SIZE (optional) shall be scalar and of type integer. The corresponding
actual argument shall not be an optional dummy argument.
Result Characteristics. The result is of the same type and type
parameters as MOLD.
Case (i): If MOLD is a scalar and SIZE is absent, the result is a scalar.
Case (ii): If MOLD is array valued and SIZE is absent, the result is
array valued and of rank one. Its size is as small as possible such
that its physical representation is not shorter than that of SOURCE.
Case (iii): If SIZE is present, the result is array valued of rank one
and size SIZE.
Result Value. If the physical representation of the result has the
same length as that of SOURCE, the physical representation of the
result is that of SOURCE. If the physical representation of the result
is longer than that of SOURCE, the physical representation of the
leading part is that of SOURCE and the remainder is undefined. If the
physical representation of the result is shorter than that of SOURCE,
the physical representation of the result is the leading part of
SOURCE. If D and E are scalar variables such that the physical
representation of D is as long as or longer than that of E, the value
of TRANSFER (TRANSFER (E, D), E) shall be the value of E. IF D is an
array and E is an array of rank one, the value of TRANSFER (TRANSFER
(E, D), E, SIZE (E)) shall be the value of E.
or... as Jakub paraphrases it:
> (4Ho wo is non-zero). The transfer_simplify_4.f90 testcase transfers an
> integer into logical and back and expects again all the 32-bits to be
> preserved.
I would say that it conforms to the standard.
Cheers
Paul