(j3.2006) Should parent component have the accessibility of the parent type?
Daniel C Chen
Thu Jan 21 21:26:52 EST 2016
Consider the following code:
Type, extends(A_t) :: B_t
Type, extends(B_t) :: C_t
Type(C_t) :: this
This%B_t%A_t%i = 4 !! NOT allowed
This%B_t%i = 4 !! Allowed
The standard states that the parent component has the accessibility of the
parent type as follows: [16-007-p80: 2-6]
"An extended type has a scalar, nonpointer, nonallocatable, parent
component with the type and type parameters
of the parent type. The name of this component is the parent type name. It
has the accessibility of the parent
type. Components of the parent component are inheritance associated (16.5.4
) with the corresponding components
inherited from the parent type. An ancestor component of a type is the
parent component of the type or an
ancestor component of the parent component."
In the above example, "This%B_t%A_t%i" is not allowed because the parent
component "A_t" of "This%B_t" has the accessibility of type A_t, which is
private in Module B so not accessible in module C. On the other hand,
"This%B_t%i" seems fine.
Is it the intention of the standard to disallow "This%B_t%A_t%i"?
XL Fortran Development - IBM Toronto Software Lab
Email: cdchen at ca.ibm.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the J3