J3/15-127 To: J3 From: Van Snyder Subject: Interpretation concerning CLASS and prior type definition Date: 2015 February 09 ---------------------------------------------------------------------- NUMBER: TBD TITLE: Is CLASS(type) required to refer to a prior type definition? KEYWORDS: CLASS, type definition DEFECT TYPE: Interpretation STATUS: J3 consideration in progress QUESTION: Does the CLASS(T) declaration of X in the following conform? recursive subroutine S ( N, X ) integer :: N class(t), optional :: X type :: T integer :: Q end type T ... ANSWER (1): Subclause 4.3.1.3 does not require the in a CLASS specifier to refer to a previously-defined type. Therefore the declaration conforms. It was intended that CLASS declarations with be parallel to TYPE declarations. In a TYPE declaration (4.3.1.2), the specified derived type is required to be previously defined, or accessed by use or host association. Therefore the example ought not to conform. Edits are provided to correct this oversight. ANSWER (2): Subclause 4.3.1.3 does not require the in a CLASS specifier to refer to a previously-defined type. Therefore the declaration conforms. Since an object declared with a CLASS specifier must be a pointer, allocatable, or dummy argument, the same sort of circular dependence, involving components, against which it is necessary to protect by requiring prior definition of a type referenced in a TYPE specifier (other than for pointer or allocatable components) is not possible. Therefore, prior definition of the type is not necessary, and the example was intended to conform. EDITS (1): [12-007:6+ 4.3.1.3p1+] Insert a paragraph: "Where a data entity other than a component is declared explicitly using the CLASS specifier to be of derived type, the specified derived type shall have been defined previously. If the data entity is a function result, the derived type may be specified in the FUNCTION statement provided the derived type is defined within the body of the function or is accessible there by use or host association. If the derived type is specified in the FUNCTION statement and is defined within the body of the function, it is as if the function result variable were declared with that derived type immediately following the of the specified derived type." {This is essentially identical to 4.3.1.2p1, except for the replacement of "TYPE" with "CLASS" and the addition of "other than a component" (4.3.1.2p1 does not mention components, but it ought to because otherwise it would contradict C440).} EDITS (2): None. SUBMITTED BY: Van Snyder HISTORY: 15-xxx m206 F08/nnnn submitted ----------------------------------------------------------------------