brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 398304b Raw
89 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Exercise ways to define and extend non-type-bound generics3 4module m15  type :: t1; end type6  type :: t2; end type7  interface operator(.eq.)8    module procedure :: eq19  end interface10  generic :: operator(==) => eq211 contains12  logical function eq1(x, y)13    type(t1), intent(in) :: x14    type(t2), intent(in) :: y15    eq1 = .true.16  end function17  logical function eq2(y, x)18    type(t2), intent(in) :: y19    type(t1), intent(in) :: x20    eq2 = .true.21  end function22  subroutine test123    type(t1) :: a24    type(t2) :: b25    if (a == b .and. b .eq. a) print *, 'ok'26  end subroutine27end module28 29module m230  use m131  type :: t3; end type32  interface operator(==)33    module procedure eq334  end interface35  generic :: operator(.eq.) => eq436 contains37  logical function eq3(x, y)38    type(t1), intent(in) :: x39    type(t3), intent(in) :: y40    eq3 = .true.41  end function42  logical function eq4(y, x)43    type(t3), intent(in) :: y44    type(t1), intent(in) :: x45    eq4 = .true.46  end function47  subroutine test248    type(t1) :: a49    type(t2) :: b50    type(t3) :: c51    if (a == b .and. b .eq. a .and. a == c .and. c .eq. a) print *, 'ok'52  end subroutine53end module54 55module m356  use m257 contains58  logical function eq5(x, y)59    type(t2), intent(in) :: x60    type(t3), intent(in) :: y61    eq5 = .true.62  end function63  logical function eq6(y, x)64    type(t3), intent(in) :: y65    type(t2), intent(in) :: x66    eq6 = .true.67  end function68  subroutine test369    interface operator(==)70      module procedure :: eq571    end interface72    type(t1) :: a73    type(t2) :: b74    type(t3) :: c75    if (a == b .and. b .eq. a .and. a == c .and. c .eq. a .and. b == c) print *, 'ok'76    block77      generic :: operator(.eq.) => eq678      if (a == b .and. b .eq. a .and. a == c .and. c .eq. a .and. b == c .and. c .eq. b) print *, 'ok'79    end block80   contains81    subroutine inner82      interface operator(.eq.)83        module procedure :: eq684      end interface85      if (a == b .and. b .eq. a .and. a == c .and. c .eq. a .and. b == c .and. c .eq. b) print *, 'ok'86    end subroutine87  end subroutine88end module89