1! RUN: %S/test_errors.sh %s %t %flang_fc1
2! REQUIRES: shell
3! Resolve generic based on number of arguments
4subroutine s1
5  interface f
6    real function f1(x)
7      optional :: x
8    end
9    real function f2(x, y)
10    end
11  end interface
12  z = f(1.0)
13  z = f(1.0, 2.0)
14  !ERROR: No specific procedure of generic 'f' matches the actual arguments
15  z = f(1.0, 2.0, 3.0)
16end
17
18! Elemental and non-element function both match: non-elemental one should be used
19subroutine s2
20  interface f
21    logical elemental function f1(x)
22      intent(in) :: x
23    end
24    real function f2(x)
25      real :: x(10)
26    end
27  end interface
28  real :: x, y(10), z
29  logical :: a
30  a = f(1.0)
31  !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types LOGICAL(4) and REAL(4)
32  a = f(y)
33end
34
35! Resolve named operator
36subroutine s3
37  interface operator(.foo.)
38    pure integer(8) function f_real(x, y)
39      real, intent(in) :: x, y
40    end
41    pure integer(8) function f_integer(x, y)
42      integer, intent(in) :: x, y
43    end
44  end interface
45  logical :: a, b, c
46  x = y .foo. z  ! OK: f_real
47  i = j .foo. k  ! OK: f_integer
48  !ERROR: No intrinsic or user-defined .FOO. matches operand types LOGICAL(4) and LOGICAL(4)
49  a = b .foo. c
50end
51
52! Generic resolves successfully but error analyzing call
53module m4
54  real, protected :: x
55  real :: y
56  interface s
57    pure subroutine s1(x)
58      real, intent(out) :: x
59    end
60    subroutine s2(x, y)
61      real :: x, y
62    end
63  end interface
64end
65subroutine s4a
66  use m4
67  real :: z
68  !OK
69  call s(z)
70end
71subroutine s4b
72  use m4
73  !ERROR: Actual argument associated with INTENT(OUT) dummy argument 'x=' must be definable
74  call s(x)
75end
76pure subroutine s4c
77  use m4
78  !ERROR: Actual argument associated with INTENT(OUT) dummy argument 'x=' must be definable
79  call s(y)
80end
81