[Patch] Fortran: Fix gfc_maybe_dereference_var [PR104430]

Tobias Burnus tobias@codesourcery.com
Mon Mar 7 14:01:59 GMT 2022

The problem is that inside the main program,
   y = f(z)
where the the result of z is
   type(t) :: z(size(x%a))
and 'x' is a dummy argument.

'x' looses the attr.dummy in gfc_add_interface_mapping
and this leads to an additional indirect ref in
gfc_maybe_dereference_var - but after the first indirect
ref, TREE_TYPE is alread a RECORD_TYPE ...

The simple fix is to simply punt when the argument
is not a pointer or reference.

This patch additionally fixes a comment in

Those parts are obvious. The only potentially risky
change is the comparison change from a name-wise comparison
to a pointer-based comparison. I think it is fine and the
testsuite did not find any issue, but you prefer, I can
also exclude it.

OK for mainline? How about GCC 10/11 backports?
(I think leaving out the last change, it should be very safe to do.)

Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr104430-class-result.diff
Type: text/x-patch
Size: 2099 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20220307/765c3b4a/attachment.bin>

More information about the Gcc-patches mailing list