https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110224
--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
Hi Neil,
Thanks for posting this bug report.
> !x%var_ptr() = 2.0 ! THIS IS NOT REJECTED AS EXPECTED
Why do you think that this should be rejected? As I understood it, this was
permitted by the definition of 'variable' in F2008:6.2 and in F2018:9.2 C902
and the definition of assignment in 10.2.1.1.
ifort accepts it and does the same with it as gfortran. nagfor throws up a
syntax error for which I am going to file a bug report unless you come up with
a contrary interpretation.
I am just going to post a fix for this PR with the testcase:
! { dg-do compile }
!
! Contributed by Neil Carlson <[email protected]>
!
module mod
type :: foo
real, pointer :: var
contains
procedure :: var_ptr
end type
contains
function var_ptr(this) result(ref)
class(foo) :: this
real, pointer :: ref
ref => this%var
end function
end module
program main
use mod
type(foo) :: x
allocate (x%var, source = 2.0)
associate (var => x%var_ptr())
var = 1.0
end associate
if (x%var .ne. 1.0) stop 1
x%var_ptr() = 2.0
if (x%var .ne. 2.0) stop 2
deallocate (x%var)
end program
Regards
Paul