llvm-project/flang/test/Semantics/bindings03.f90
Peter Klausler fee041f69d [flang] Document and warn about an extension
Standard Fortran allows type-bound procedure bindings to only
be called, and disallows them from being used in other contexts
where a procedure name can be: as the target of a procedure pointer
assignment statement, and as an actual argument that corresponds
to a dummy procedure.  So long as the interfaces match, there's
no good reason for these uses to be errors, and there some obvious
use cases in polymorphic programming.  So emit portability warnings
rather than errors, and document this usage as an extension.

Differential Revision: https://reviews.llvm.org/D139127
2022-12-03 11:09:59 -08:00

27 lines
603 B
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror
! Confirm a portability warning on use of a procedure binding apart from a call
module m
type t
contains
procedure :: sub
end type
contains
subroutine sub(x)
class(t), intent(in) :: x
end subroutine
end module
program test
use m
procedure(sub), pointer :: p
type(t) x
!PORTABILITY: Procedure binding 'sub' used as target of a pointer assignment
p => x%sub
!PORTABILITY: Procedure binding 'sub' passed as an actual argument
call sub2(x%sub)
contains
subroutine sub2(s)
procedure(sub) s
end subroutine
end