63 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12 3! Check distinguishability for specific procedures of defined operators and4! assignment. These are different from names because there a normal generic5! is invoked the same way as a type-bound generic.6! E.g. for a generic name like 'foo', the generic name is invoked as 'foo(x, y)'7! while the type-bound generic is invoked as 'x%foo(y)'.8! But for 'operator(.foo.)', it is 'x .foo. y' in either case.9! So to check the specifics of 'operator(.foo.)' we have to consider all10! definitions of it visible in the current scope.11 12! One operator(.foo.) comes from interface-stmt, the other is type-bound.13module m114 type :: t115 contains16 procedure, pass :: p => s117 generic :: operator(.foo.) => p18 end type19 type :: t220 end type21 !ERROR: Generic 'OPERATOR(.foo.)' may not have specific procedures 's2' and 't1%p' as their interfaces are not distinguishable22 interface operator(.foo.)23 procedure :: s224 end interface25contains26 integer function s1(x1, x2)27 class(t1), intent(in) :: x128 class(t2), intent(in) :: x229 end30 integer function s2(x1, x2)31 class(t1), intent(in) :: x132 class(t2), intent(in) :: x233 end34end module35 36! assignment(=) as type-bound generic in each type37module m238 type :: t139 integer :: n40 contains41 procedure, pass(x1) :: p1 => s142 !ERROR: Generic 'assignment(=)' may not have specific procedures 't1%p1' and 't2%p2' as their interfaces are not distinguishable43 generic :: assignment(=) => p144 end type45 type :: t246 integer :: n47 contains48 procedure, pass(x2) :: p2 => s249 generic :: assignment(=) => p250 end type51contains52 subroutine s1(x1, x2)53 class(t1), intent(out) :: x154 class(t2), intent(in) :: x255 x1%n = x2%n + 156 end subroutine57 subroutine s2(x1, x2)58 class(t1), intent(out) :: x159 class(t2), intent(in) :: x260 x1%n = x2%n + 261 end subroutine62end module63