This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question about generated type for common block in fortran
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Michael Matz <matz at suse dot de>
- Cc: "Bin.Cheng" <amker dot cheng at gmail dot com>, gfortran at gcc dot gnu dot org, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Eric Botcazou <ebotcazou at adacore dot com>
- Date: Mon, 13 Nov 2017 11:39:50 +0100
- Subject: Re: Question about generated type for common block in fortran
- Authentication-results: sourceware.org; auth=none
- References: <CAHFci2-Ou3jwFk0v=_hrUpeSHCpVM-Lb9JnTNDckmieAzTkzvQ@mail.gmail.com> <F09FC826-F13A-4E39-A24F-3D9E37628A92@gmail.com> <alpine.LSU.2.21.1711071650200.25295@wotan.suse.de> <CAFiYyc1qy7nfZFoT9g90ecx6SBU5P9s_9=Rtte6x+F_kfNKrJw@mail.gmail.com> <alpine.LSU.2.21.1711081541170.25295@wotan.suse.de> <CAFiYyc1d=PT-C4n2GLfjUX=uLJoZSw87JkGLktJuq03iTAxNLQ@mail.gmail.com> <CAHFci29Xni=k4EFPcbBgKSDrYRozwL3jMbtmPCM4AZ8Pu=S0Ww@mail.gmail.com> <alpine.LSU.2.21.1711131050540.25295@wotan.suse.de>
On Mon, Nov 13, 2017 at 11:01 AM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Thu, 9 Nov 2017, Bin.Cheng wrote:
>
>> So I have two questions here.
>> A) Is this special kind union type only generated by fortran FE for
>> equivalence+common?
>
> It's not special in that it isn't marked in any way. For all purposes
> it's a normal union type with surprising field(offset)s. I don't know if
> it can occur for any situations except equivalence+common. Not from the
> fortran frontend I believe.
>
>> B) For the special union type that has non-zero offset fields. Is it
>> safe to assume field A is not the last flex array: if there is field B
>> that offset_B >= (offset_A + length_A)?
>
> No. You can make equivalences between all kinds of objects,
> including non-arrays. You can also equivalence (say) an integer variable
> and an individual array element. Also flex arrays don't enter the
> picture, you can equivalize (tm) also arrays of fixed size.
Just a remark on the optimization you want to achieve. Rather than
trying to fix things through max_size and friends you can also look
at nonoverlapping_component_refs_of_decl_p and/or
nonoverlapping_component_refs_p both of which currently punt
for UNION_TYPEs.
So I was thinking of a good condition to quickly decide whether UNION_TYPE
fields may overlap or not (and thus to distinguish the Fortran case which then
requires more elaborate processing).
A simple one might be to quickly bail out if DECL_FIELD_[BIT_]OFFSET
are the same.
This might be a more local "fix" for the missed aliasing than trying to
jump into the flex array issues.
Richard.
>
> Ciao,
> Michael.