This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: RFC: (PR 45586) Pointer, target, and alias analysis of derived types (RESTRICT qualifier)
- From: Michael Matz <matz at suse dot de>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: gfortran <fortran at gcc dot gnu dot org>, Richard Guenther <rguenther at suse dot de>
- Date: Tue, 26 Jul 2011 17:51:54 +0200 (CEST)
- Subject: Re: RFC: (PR 45586) Pointer, target, and alias analysis of derived types (RESTRICT qualifier)
- References: <4E2ED346.6020404@net-b.de>
Hi,
On Tue, 26 Jul 2011, Tobias Burnus wrote:
> a) Fortran question: My understanding is that any POINTER/TARGET attribute
> propagates through such that the last-ref can/is a pointer target. Example:
>
> TYPE realspace_grid_type
> REAL(KIND=dp), DIMENSION ( :, :, : ), ALLOCATABLE :: r
> END TYPE realspace_grid_type
>
> Here, "r" cannot be a pointer target, unless, one has, e.g.,
>
> TYPE realspace_grid_p_type
> TYPE(realspace_grid_type), POINTER :: rs_grid
> END TYPE realspace_grid_p_type
>
> such that "rs_grid"'s pointer target has TARGET attribute such that also "r"
> has the target attirbute. Is this correct?
It seems so. realspace_grid_type.r can have restrict set, but
realspace_grid_p_type.rs_grid.r cannot. Hence the type of the FIELD_DECL
corresponding to rs_grid needs to have a nonrestrict type, exactly because
of the pointer modifier in that type definition. Therefore if something
needs to change it is in actually building the RECORD_TYPE from the
frontend representation, and hence ...
> b) GCC/gfortran code question: Is the following patch correct and sufficient?
> It does not ICE, but I am not sure whether that's sufficient. (Before, it
> ICEed with -flto, cf. comment 53.)
>
> --- a/gcc/fortran/trans-types.c
> +++ b/gcc/fortran/trans-types.c
> @@ -2421,6 +2421,9 @@ gfc_get_derived_type (gfc_symbol * derived)
> && !c->attr.proc_pointer)
> field_type = build_pointer_type (field_type);
>
> + if (c->attr.pointer)
> + field_type = gfc_nonrestricted_type (field_type);
> +
> /* vtype fields can point to different types to the base type. */
> if (c->ts.type == BT_DERIVED&& c->ts.u.derived->attr.vtype)
> field_type = build_pointer_type_for_mode (TREE_TYPE (field_type),
... this seems to be the right thing. But it probably also needs to do
the same for c->attr.target, right? E.g. for:
TYPE murks
TYPE(realspace_grid_type), TARGET :: rs_grid
END TYPE murks
I'm not sure if murks.rs_grid.r needs to have a nonrestrict type. The
fortran standard seems to imply this, doesn't it? (As in, rs_grid.r also
has the target attribute implicitely).
Ciao,
Michael.