https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64678
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #1 from kargl at gcc dot gnu.org --- (In reply to Antony Lewis from comment #0) > In trunk > > module X > Type T > integer :: map > end Type T > contains > > subroutine DoBug > Type(T) TT > > associate(A=>TT, B=>A%map) > end associate > > end subroutine > end module X > > gives: > > testbug.f90:10:17: > > associate(A=>TT, B=>A%map) > 1 > Error: Expected association at (1) > testbug.f90:11:4: > > end associate > 1 > > It's not entirely clear to me from the standard if this is allowed, but I > don't see why not (useful when you are breaking up complicated array/class > structures into associate names, where the second name refers to the first). > It compiles in ifort. Obviously low priority as can be worked around easily > enough I believe gfortran is correct in issuing an error; although I admit it seems to be a subtle distinction in language. For F2003 standard 8.1.4 ASSOCIATE construct The ASSOCIATE construct associates named entities with expressions or variables during the execution of its block. These named construct entities (16.3) are associating entities (16.4.1.5). The names are associate names. The BNF shows R818 association is associate-name => selector R819 selector is expr or variable In your code, 'A' and 'B' are associate-names. The target of an associate-name is a selector, which is an expr or variable. The target for 'B' is 'A%map'. So, the question becomes whether 'A%map' is now a variable or expression even though 'A' is an associate-name. The BNF for 'variable is R601 variable is designator C601 (R601) designator shall not be a constant or a subobject of a constant. R602 variable-name is name C602 (R602) A variable-name shall be the name of a variable. R603 designator is object-name or array-element or array-section or structure-component or substring R505 object-name is name C505 (R505) The object-name shall be the name of a data object. A data object (often abbreviated to object) is a constant (4.1.2), a variable (6), or a subobject of a constant. The type and type parameters of a named data object may be specified explicitly (5.1) or implicitly (5.3). 'A%map' as a data object is certainly not a constant or subobject of a constant, so it must be a variable. But, we've already established that 'A' is an associate-name not a variable-name. So, 'A%map' is not an object-name. array-element, array-section, and substring are of no consequence here. So, now, structure-component R614 structure-component is data-ref R612 data-ref is part-ref [ % part-ref ] ... R613 part-ref is part-name [ ( section-subscript-list ) ] C612 (R612) The leftmost part-name shall be the name of a data object. We've already established 'A' is not a data object. So, now we are left with 'expr'. I have no interest in reproducing Section 7 of Fortran 2003 standard. I suspect you'll find that 'A%map' is not an 'expr'. Note, I could be wrong. You may want to post to comp.lang.fortran. There are numerous people, who contribute to c.l.f, that are much more in-tune with the nuances of the Fortran standard.