To: J3 Members J3/17-184 From: Van Snyder Subject: Implicit declaration and BLOCK constructs References: 17-007r2 Date: 2017 July 28 1. Discussion ============= Subclause 8.7p4 says that if a variable in a BLOCK construct is not explicitly declared in a type declaration statement, and the outermost inclusive scope is not a type definition, the effect is as if it were explicitly declared in the outermost inclusive scope in which it appears, which (according to the definition of inclusive scope) would apparently not be the BLOCK construct. Subclause 19.4p1 says that an entity that is explicitly declared in the specification part of a BLOCK construct, other than only in ASYNCHRONOUS and VOLATILE statements, is a construct entity. 19.4p1 does not restrict the declaration to type declaration statements. At least three processors accept the following and appear to agree that the variable R in each block is a construct entity, in that they print different values for their shapes: program P block dimension R(3) print '(a,i0)', 'Shape(R) = ', shape(r) end block block dimension R(2,2) print '(a,2(1x,i0))', 'Shape(R) = ', shape(r) end block end program P Shape(R) = 3 Shape(R) = 2 2 It is clear that they do not consider R to be declared as two arrays with different ranks in the inclusive scope of the BLOCK constructs. It cannot be determined (except maybe by looking at generated code) whether they declared a scalar named R in the inclusive scope. Subclauses 8.7p4 and 19.4p1 ought to be consistent. So as not to require changes to the three processors that behave as above, the scope of declaration specified in 8.7p4 ought to be the outermost scope containing the object if it is declared in any statement, not the outermost inclusive scope. Since it is apparently not possible to detect whether a variable that is not explicitly declared in any statement within a BLOCK construct is or is not a construct entity, it would be simpler if variables either explicitly or implicitly declared in BLOCK constructs were construct entities, except those accessed by host association and declared only in ASYNCHRONOUS or VOLATILE statements. In program Q block asynchronous :: A end block end program Q subclause 19.4p1 says that A is not a construct entity. According to (currently defective) 8.7p4, A is declared in the scope of program Q, which is inconsistent with declarations of R in program P above. To make it clear that A is a construct entity, the description of ASYNCHRONOUS and VOLATILE in 19.4p1 should explicitly apply only to entities accessed by host association. 2. Edits ======== [121:7 8.7p4 IMPLICIT statement] Delete "inclusive". [516:12 19.4p1 Statement and construct entities] After "explicitly" with "explicitly or implicitly". In light of 8.7p4 saying "as if ... explicitly" this might not be necessary. [516:13 19.4p1 Statement and construct entities] Replace "only in ASYNCHRONOUS and VOLATILE" with "one accessed by host association and declared only in ASYNCHRONOUS or VOLATILE".