This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] Fix ICE with class array references.


this patch, extracted with some modifications from PR50981 comment #28
(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

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?


Attachment: fix_class_refs.CL
Description: Text document

Attachment: fix_class_refs.diff
Description: Text document

Attachment: fix_class_refs-tests.CL
Description: Text document

Attachment: class_array_10.f03
Description: Text document

Attachment: class_array_11.f03
Description: Text document

Attachment: class_array_12.f03
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]