Peter Klausler 2f999cce19 [flang] Respect function vs subroutine distinction in generic matching
When checking the specific procedures of a generic interface for a
match against a given set of actual arguments, be sure to not match
a function against a subroutine call or vice versa.  (We generally
catch and warn about attempts to declare mixed interfaces, but they
are usually conforming and can be inadvertently created when generics
are merged due to USE and host association.)

Differential Revision: https://reviews.llvm.org/D139059
2022-12-03 07:53:04 -08:00

35 lines
807 B
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
! Test resolution of type-bound generics.
module m1
type :: t
contains
procedure, pass(x) :: add1 => add
procedure, nopass :: add2 => add
procedure :: add_real
generic :: g => add1, add2, add_real
end type
contains
integer function add(x, y)
class(t), intent(in) :: x, y
end
integer function add_real(x, y)
class(t), intent(in) :: x
real, intent(in) :: y
end
subroutine test1(x, y, z)
type(t) :: x
integer :: y
integer :: z
!ERROR: No specific function of generic 'g' matches the actual arguments
z = x%g(y)
end
subroutine test2(x, y, z)
type(t) :: x
real :: y
integer :: z
!ERROR: No specific function of generic 'g' matches the actual arguments
z = x%g(x, y)
end
end