J3/14-154r3 To: J3 From: Van Snyder & Malcolm Cohen Subject: Interp concerning LOCK_TYPE Date: 2014 June 27 ---------------------------------------------------------------------- NUMBER: F08/0107 TITLE: LOCK_TYPE, ultimate components, subcomponents, and coarrays KEYWORD: LOCK_TYPE, ultimate components, subcomponents, coarrays DEFECT TYPE: Erratum STATUS: J3 consideration in progress DISCUSSION: Constraint C433 in subclause 4.5.2.1 reads: C433 (R425) If EXTENDS appears and the type being defined has an ultimate component of type LOCK_TYPE from the intrinsic module ISO FORTRAN ENV, its parent type shall have an ultimate component of type LOCK TYPE. This was intended to prevent compromising protection of objects of type LOCK_TYPE by using type extension and polymorphism. According to subclause 1.3.33.4, an ultimate component is a component that is of intrinsic type, a pointer, or allocatable; or an ultimate component of a nonpointer nonallocatable component of derived type The type LOCK_TYPE is not intrinsic. Therefore, if a type has a nonallocatable component of type LOCK_TYPE, it does not have an ultimate component of type LOCK_TYPE. Therefore, constraint C433 fails to protect entities of type LOCK_TYPE. Constraint C433 prohibits reasonable constructions, such as extending the type LOCK_TYPE, or extending a type that has an allocatable component that has a component of type LOCK_TYPE, because the parent type does not have an ultimate component of type LOCK_TYPE. Constraint C1302 in subclause 13.8.2.16 reads: C1302 A named variable of type LOCK TYPE shall be a coarray. A named variable with a noncoarray subcomponent of type LOCK TYPE shall be a coarray. This was intended to require that components of type LOCK_TYPE, at any level of component selection, be coarrays. According to subclause 1.3.33.3, a subcomponent is a direct component that is a subobject of a structure According to subclause 1.3.33.1, a direct component is one of the components, or one of the direct components of a nonpointer nonallocatable component. The definition of the term "subcomponent" does not include components of allocatable components. Therefore, because of the use of the term "subcomponent," if an object has an allocatable component that in turn has a component of type LOCK_TYPE, C1302 can fail to require a component of type LOCK_TYPE to be a coarray. QUESTIONS: Assume type LOCK_TYPE from ISO_Fortran_Env is accessible. 1. Is the definition of type One below standard conforming? type, extends(LOCK_TYPE) :: One type(lock_type), allocatable :: LOCK end type One 2. Is the definition of type Four below standard conforming? type :: Two type(lock_type), allocatable :: LOCK[:] end type Two type :: Three type(two), allocatable :: L end type Three Type, extends(Three) :: Four type(lock_type), allocatable :: LOCK[:] end type Four 3. Is the definition of type Six below standard conforming? type :: Five end type Five type, extends(Five) :: Six type(two), allocatable :: L end type Six 4. Is the declaration of the variable X below standard conforming? type :: Seven type(lock_type) :: L end type Seven type :: Eight type(seven), allocatable :: C end type Eight type(eight) :: X ANSWERS: 1. This was intended to be permitted. An edit is provided to repair the constraint on adding a LOCK_TYPE component during type extension. 2. This was intended to be permitted. An edit is provided to repair the constraint on adding a LOCK_TYPE component during type extension. 3. This was not intended to be permitted. An edit is provided to repair the constraint on adding a LOCK_TYPE component during type extension. 4. This was not intended to be permitted. An edit is provided to repair the constraint on declaring objects which have a potential subobject of type LOCK_TYPE. EDITS: [6:7+] After definition 1.3.33.2 parent component, insert new term "1.3.33.2a potential subobject component nonpointer component, or potential subobject component of a nonpointer component (4.5.1)". [61:27-29] 4.5.2.1 Syntax, C433, "ultimate" -> "potential subobject", twice. After "parent type" insert "shall be LOCK_TYPE or". [127:8-9] 6.7.1.1 Syntax, C642, split into two constraints as follows: "C642 If an is a coarray, the declared type of shall not be C_PTR or C_FUNPTR. C642a If an is a coarray, the declared type of in a SOURCE= specifier shall not be LOCK_TYPE (13.8.2.16), nor shall it have a potential subobject component of type LOCK_TYPE." {Fix subobject component, there is no problem with MOLD=.} [127:18-19] 6.7.1.1, p4, "If" -> "If an ALLOCATE statement has a SOURCE= clause and an", {There is no problem with MOLD=. "subcomponent" works ok here because we have an object not a type.} [399:17-18] 13.8.2.16 LOCK_TYPE, C1302, Change "with a noncoarray subcomponent" to "of a type that has a noncoarray potential subobject component". {Constraints need to be about the type,} ALTERNATIVE replace entire constraint with "C1302 A named variable shall be a coarray if its declared type is LOCK_TYPE or has a potential subobject component whose declared type is LOCK_TYPE." {This makes it clear that we are talking about the declared type.} SUBMITTED BY: Van Snyder HISTORY: m204 14-154 F08/0107 submitted m204 14-154r3 Revised ----------------------------------------------------------------------