Janus Weil wrote:
here is a straightforward patch to teach 'get_expr_storage_size' about
type-bound procedures (which are handled internally as
procedure-pointer components of the corresponding vtab). In that sense
the patch should handle both TBPs as well as PPCs.
Regtested on x86_64-unknown-linux-gnu. Ok for trunk?
The patch is NOT okay:
+ else if (ref->type == REF_COMPONENT && ref->u.c.component->attr.function
+ && ref->u.c.component->attr.proc_pointer
+ && ref->u.c.component->attr.dimension)
+ {
+ /* Array-valued procedure-pointer components. */
+ gfc_array_spec *as = ref->u.c.component->as;
+ for (i = 0; i < as->rank; i++)
+ elements = elements
+ * (mpz_get_si (as->upper[i]->value.integer)
+ - mpz_get_si (as->lower[i]->value.integer) + 1L);
You cannot assume that the function returns an explicit size array with
constant bounds. The code simply breaks (ICE) if you use, e.g.,
call func1 (phs%decay_p (2))
with
function decay_p (n)
real :: decay_p(n)
decay_p = 1.
end function
or for instance
function decay_p (n)
real, allocatable :: decay_p(:)
decay_p = [1.]
end function
Tobias