To: J3 J3/16-210 From: Steve Lionel Subject: Nested USE and Local Entities Date: 2016 May 31 Reference: 16-007r1 Consider the following program: MODULE A INTEGER :: P = 42 END MODULE A MODULE B USE A END MODULE B PROGRAM NEST USE A USE B PRINT *, P END PROGRAM NEST 11.2.2p8 says "Two or more accessible entities, other than generic interfaces or defined operators, may have the same local identifier only if the identifier is not used." It is clear from 11.2.2 that module B has a "local entity" P and of course module A has a "local entity" P. Are these the same entity, in which case the use of P in the program is allowed, or different entities? There is no text I can find addressing this, other than comments in example C.8.3.7. It seems clear that our intent was that this program is allowed - if it weren't, a lot of existing code would break - but there needs to be text added to address nested USE. Now consider if module B were: MODULE B USE A VOLATILE P END MODULE B The standard allows a local entity to be given the ASYNCHRONOUS or VOLATILE attribute even if the use-associated entity doesn't have it. Now what about P in the program? Does it have VOLATILE or not? Through one path it does, through another path it doesn't. Are these the same or different entities? The current text does not prohibit this inconsistent set of attributes. Edits are suggested to address both of these issues. EDITS TO 16-007r1 [290:10, 11.2.2p8+ The USE statement and use association] Insert the following sentence at the beginning of the paragraph ("Two or more accessible entities...")" "An ultimate entity is a module entity not defined by use association." and insert the word "ultimate" after "accessible" in the now-second sentence. The paragraph now reads: "An ultimate entity is a module entity not defined by use association. Two or more accessible ultimate entities, other than generic interfaces or defined operators, may have the same local identifier only if the identifier is not used. Generic interfaces and defined operators are handled as described in 12.4.3.5. Except for these cases, the local identifier of any entity given accessibility by a USE statement shall differ from the local identifiers of all other entities accessible to the scoping unit." [290:17+, 12.2.2p9+] Insert the paragraph: "If a use-defined entity is made accessible through more than one use path, has the ASYNCHRONOUS or VOLATILE attribute in any of those use paths, and is not given that attribute in the current scoping unit, it must have that same attribute in all use paths." [569:13-14, C.8.3.7, Public entities renamed] No edits needed for the comments in this example.