[Patch, fortran] Fix ICE with class array references.
Mikael Morin
mikael.morin@sfr.fr
Thu Feb 2 14:21:00 GMT 2012
Hello,
this patch, extracted with some modifications from PR50981 comment #28
[http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50981#c28],
(which has accumulated a lot of things) fixes an ICE noticed in several
PRs with an error like:
internal compiler error: in gfc_conv_descriptor_data_get,
at fortran/trans-array.c:147
internal compiler error: in gfc_conv_descriptor_offset, at
fortran/trans-array.c:210
the problem is a missing "_data" reference (to escape the class
container) when trying to access a subobject of a class object.
The solution proposed is to replace the call to
gfc_add_component_ref(expr, "_data") with a call to a new, more general,
function gfc_fix_class_refs which takes care of adding the "_data"
component in all references (not only the last one) where it is missing.
Thus, it works
- in the scalar case: class%array_comp(1), class%scalar_comp
- with multiple level of components: class%comp%subclass%sub_comp
- in the array case (but this was working before): class%array_comp(:)
- in any mix of the above cases.
I have chosen to make it a separate function instead of fixing
gfc_add_component_ref, so that it can be reused later (maybe...) even if
we don't want to add a "_data", or "_vptr" or ... component.
W.R.T. the code itself, I think it is rather straightforward. There is
an odd thing to prevent a regression in class_41.f03. See the big
comment in class_data_ref_missing.
Regression tested on x86_64-unknown-freebsd9.0. OK for trunk?
Mikael
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fix_class_refs.CL
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120202/fa75d449/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fix_class_refs.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120202/fa75d449/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fix_class_refs-tests.CL
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120202/fa75d449/attachment-0002.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: class_array_10.f03
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120202/fa75d449/attachment-0003.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: class_array_11.f03
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120202/fa75d449/attachment-0004.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: class_array_12.f03
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120202/fa75d449/attachment-0005.ksh>
More information about the Fortran
mailing list