mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 03:56:42 +00:00

A reference to a pointer-valued function is a "variable" in the argot of the Fortran standard, and can be the left-hand side of an assignment statement or passed as a definable actual argument -- but it is not a definable pointer, and cannot be associated with a pointer dummy argument that is not INTENT(IN). Differential Revision: https://reviews.llvm.org/D143827
28 lines
575 B
Fortran
28 lines
575 B
Fortran
! RUN: %python %S/test_errors.py %s %flang_fc1
|
|
module m
|
|
integer, target :: n
|
|
contains
|
|
function ptr()
|
|
integer, pointer :: ptr
|
|
ptr => n
|
|
end
|
|
subroutine s1(p)
|
|
integer, pointer, intent(in) :: p
|
|
end
|
|
subroutine s2(p)
|
|
integer, pointer, intent(in out) :: p
|
|
end
|
|
end
|
|
|
|
program test
|
|
use m
|
|
integer, pointer :: p
|
|
p => ptr() ! ok
|
|
ptr() = 1 ! ok
|
|
call s1(ptr()) ! ok
|
|
call s1(null()) ! ok
|
|
!ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'p=' is not definable
|
|
!BECAUSE: 'ptr()' is not a definable pointer
|
|
call s2(ptr())
|
|
end
|