https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125012
--- Comment #1 from Ivan Pribec <ivan.pribec at gmail dot com> ---
With flang, ifort, ifx, nagfor, the example also works if the function point()
is an internal procedure:
program assoc
implicit none
real :: pi(1)
associate (points => point() )
pi(:) = points%x ! REJECTED
end associate
print *, pi
associate (points => (point()))
pi(:) = points%x ! REJECTED
end associate
print *, pi
associate (points => [point()])
pi(:) = points%x ! REJECTED
end associate
print *, pi
contains
function point() result(p)
type :: point_
real :: x = 42.
end type point_
type(point_) :: p
end function
end program
While the derived type point_ could be hoisted outside, the purpose of this
specific pattern is to keep the type private and force the programmer to use an
associate block.