J3/16-159 To: J3 Members From: Daniel Chen Subject: Edit: Accessibility of a parent component Date: 2016 February 07 References: 16-007 QUESTION: There has been discussions via email about when a parent component is accessible. The standard states that the parent component has the accessibility of the parent type as follows: [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." Is the accessibility of the parent type mentioned in the above referring to the scoping unit in which the parent type is declared or the scoping unit where the parent component is referenced? Consider the following two programs: A. Is the following program standard comforming? Module A private Type A_t Integer i End type Public A_t End module Module B Use A private Type, extends(A_t) :: B_t End type Public B_t End module Module C Use B Type, extends(B_t) :: C_t End type Contains Subroutine sub(this) Type(C_t) :: this This%B_t%A_t%i = 4 !! 1. Is This%B_t%A_t%i accessible? This%B_t%i = 4 !! 2. Is This%B_t%i accessible? End End module B. Module AB private Type A_t Integer i End type Type, extends(A_t) :: B_t End type Public B_t End module Module C Use AB Type, extends(B_t) :: C_t End type Contains Subroutine sub(this) Type(C_t) :: this This%B_t%A_t%i = 4 !! 1. Is This%B_t%A_t%i accessible? This%B_t%i = 4 !! 2. Is This%B_t%i accessible? End End module ANSWER: The intention of the standard is that a parent component has the accessibility of the parent type in the scoping unit where it is declared. Therefore, Program A: 1 is accessible 2 is accessible Program B: 1 is not accessible 2 is accessible An edit is provided to clarify it. EDITS to 16-007: [80: 4] In 4.5.7.2 Inheritance, paragraph 2, after "type", add "in the scoping unit where it is declared" SUBMITTED BY: Daniel Chen