To: J3 J3/17-253r1 From: Robert Corbett Subject: IMPORT statements in BLOCK constructs Date: 2017 October 19 Reference: 17-007r2 1. Discussion The specification of the IMPORT statement in subclause 8.8 of 17-007r2 describes the semantics of IMPORT statements in terms of their effects on host association. Host association does not apply to entities in BLOCK constructs. The mechanism for accessing entities in enclosing scoping units from within BLOCK constructs is inclusive scoping, not host association. As currently described, IMPORT statements have no effect on BLOCK constructs. For example, consider the program PROGRAM MAIN IMPLICIT NONE REAL :: X = 1.0 A: BLOCK IMPORT, NONE PRINT *, X END BLOCK A END According to subclause 8.8p2, the statement IMPORT, NONE specifies that no entities in the host scoping unit of BLOCK A are made accessible within BLOCK A by host association. However, because the scope of the variable X includes BLOCK A, the variable X is accessible within BLOCK A. Therefore, the program is conformant. Users might be surprised that the statement IMPORT, NONE leaves the variable X accessible in the BLOCK construct. Edits are provided to make the semantics of IMPORT statements work for BLOCK constructs. A note has been added illustrating a tricky case. 2. Edits to 17-007r2 [123:19] 8.8 IMPORT statement, p1 Insert " other than a BLOCK construct" between "in a scoping unit" and ", an entity". {The resulting sentence is "If the ONLY specifier appears on an IMPORT statement in a scoping unit other than a BLOCK construct, an entity is only accessible by host association if its name appears as an in that scoping unit.".} [123:20] 8.8 IMPORT statement, p1 Insert "If a BLOCK construct contains one or more IMPORT statements with ONLY specifiers, identifiers of local and construct entities in the host scoping unit that are not in the of at least one of the IMPORT statements are inaccessible in the BLOCK construct." after "that scoping unit". [123:23] 8.8 IMPORT statement, p2 Insert "An IMPORT, NONE statement in a BLOCK construct specifies that the identifiers of local and construct entities in the host scoping unit are inaccessible in the BLOCK construct." after "procedure." [123:25] 8.8 IMPORT statement, p3 Delete "by host association" {The resulting sentence is "An IMPORT, ALL statement in a scoping unit specifies that all entities from the host scoping unit are accessible in that scoping unit."} [123:30-31] 8.8 IMPORT statement, p5 Replace "in a scoping unit ... host association." with "in a scoping unit other than a BLOCK construct, each entity named in the list is accessible.". {The resulting sentence is "If an IMPORT statement with an appears in a scoping unit other than a BLOCK construct, each entity named in the list is accessible."} [124] 8.8 IMPORT statement, after NOTE 8.44 Insert "NOTE 8.44a The program PROGRAM MAIN BLOCK IMPORT, NONE !IMPORT, ONLY: X X = 1.0 END BLOCK END is not conformant. The variable X is implicitly declared in the scoping unit of the main program. The statement IMPORT, NONE makes X inaccessible in the BLOCK construct. If the IMPORT, NONE statement is replaced with the IMPORT statement in the comment, the program is conformant." [513:9] 19.1 Scopes, identifiers, and entities Insert ", or where an IMPORT statement (8.8) makes the identifier inaccessible" after "(19.3, 19.4)" and before the full stop. {19.3 refers to the subclause titled "Local identifiers".} {19.4 refers to the subclause titled "Statement and construct entities".}