User account creation filtered due to spam.
Created attachment 27798 [details]
Draft patch - should be sufficient, but isn't.
The main purpose of the proposed change is the handling of assumed-rank arrays, both implementation wise and by allowing to bump the MAX_DIMENSION without breaking the ABI.
The attached patch should be sufficient, but it causes many test suite failures, e.g. by having a __vtype in the call to class.c's find_typebound_proc_uop. For that argument, derived->f2k_derived == NULL, which triggers an assert for gfortran.dg/abstract_type_6.f03.
Currently, the first element in a class container is _data, followed by _vptr.
_data can be either directly a memory address or array descriptor of rank n. Hence, the byte-offset between the base address of the class container and the _vptr depends on the kind of data (normal scalar vs. array) and the rank.
For assumed-shape arrays, that implies that one always needs to have an array descriptor of MAX_DIMENSION – and changing MAX_DIMENSION will break the arrays.
If one reorder _vptr and _data, _vptr can be always accessed and one can directly pass class containers (with descriptor) of any rank – the size of the array container is then known at run time based on the rank information.
In C syntax, that's
/* First fields of the array descriptor. */
array_dim_triplet dim[ ];
Where the "[ ]" allows for different lengths; it is created by creating a tree-decl for an array of size 0.
The current assumed-rank patch, has always MAX_DIMENSION and copies all fields including the dimension triplet (the latter via range-ref) over.
(In reply to comment #0)
> The attached patch should be sufficient, but it causes many test suite
> failures, e.g. by having a __vtype in the call to class.c's
> find_typebound_proc_uop. For that argument, derived->f2k_derived == NULL, which
> triggers an assert for gfortran.dg/abstract_type_6.f03.
Hello, you may also look at conv_parent_component_references.
This function is normally used with extended derived types to access a field in the base object: an implicit reference to the base type object (first field in the extended one) is automatically added.
I don't remember the details, but I think that in some cases, it was fed with a class container and was also doing the "right" thing in those cases (accessing the object itself, and then one of its subfield).
Not sure whether it is relevant anymore as we now have calls to gfc_fix_class_refs, which makes the implicit references explicit.
Anyway, even if it's not anymore relevant, I'm afraid there are many places we use derived->components where we should have used gfc_find_component(derived, "_data") :-(.