xref: /llvm-project/flang/test/Semantics/generic03.f90 (revision 2f999cce195946b66f968d50e38b06e6a1f60b8e)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Exercise function vs subroutine distinction in generics
3module m1
4  type t1
5    integer n
6  end type
7  interface g1
8    integer function f1(x, j)
9      import t1
10      class(t1), intent(in out) :: x
11      integer, intent(in) :: j
12    end
13  end interface
14end module
15
16program test
17  use m1
18  !WARNING: Generic interface 'g1' has both a function and a subroutine
19  interface g1
20    subroutine s1(x, a)
21      import t1
22      class(t1), intent(in out) :: x
23      real, intent(in) :: a
24    end subroutine
25  end interface
26  type(t1) :: x
27  print *, g1(x,1) ! ok
28  !ERROR: No specific function of generic 'g1' matches the actual arguments
29  print *, g1(x,1.)
30  !ERROR: No specific subroutine of generic 'g1' matches the actual arguments
31  call g1(x,1)
32  call g1(x, 1.) ! ok
33 contains
34end
35