brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.3 KiB · 5f685c0 Raw
252 lines · plain
1! RUN: %python %S/test_modfile.py %s %flang_fc12module m13  type :: t14  contains5    procedure, pass(x) :: p1 => f6    procedure, non_overridable :: p2 => f7    procedure, nopass :: p3 => f8    generic :: operator(+) => p19    generic :: operator(-) => p210    generic :: operator(<) => p111    generic :: operator(.and.) => p212  end type13contains14  integer(8) pure function f(x, y)15    class(t1), intent(in) :: x16    integer, intent(in) :: y17  end18  ! Operators resolve to type-bound operators in t119  subroutine test1(x, y, a, b)20    class(t1) :: x21    integer :: y22    real :: a(x + y)23    real :: b(x .lt. y)24  end25  ! Operators resolve to type-bound operators in t1, compile-time resolvable26  subroutine test2(x, y, a, b)27    class(t1) :: x28    integer :: y29    real :: a(x - y)30    real :: b(x .and. y)31  end32  ! Operators resolve to type-bound operators in t1, compile-time resolvable33  subroutine test3(x, y, a)34    type(t1) :: x35    integer :: y36    real :: a(x + y)37  end38end39!Expect: m1.mod40!module m141! type :: t142! contains43!  procedure, pass(x) :: p1 => f44!  procedure, non_overridable :: p2 => f45!  procedure, nopass :: p3 => f46!  generic :: operator(+) => p147!  generic :: operator(-) => p248!  generic :: operator(<) => p149!  generic :: operator(.and.) => p250! end type51!contains52! pure function f(x, y)53!  class(t1), intent(in) :: x54!  integer(4), intent(in) :: y55!  integer(8) :: f56! end57! subroutine test1(x, y, a, b)58!  class(t1) :: x59!  integer(4) :: y60!  real(4) :: a(1_8:x%p1(y))61!  real(4) :: b(1_8:x%p1(y))62! end63! subroutine test2(x, y, a, b)64!  class(t1) :: x65!  integer(4) :: y66!  real(4) :: a(1_8:f(x, y))67!  real(4) :: b(1_8:f(x, y))68! end69! subroutine test3(x,y,a)70!  type(t1) :: x71!  integer(4) :: y72!  real(4) :: a(1_8:f(x,y))73! end74!end75 76module m277  type :: t178  contains79    procedure, pass(x) :: p1 => f180    generic :: operator(+) => p181  end type82  type, extends(t1) :: t283  contains84    procedure, pass(y) :: p2 => f285    generic :: operator(+) => p286  end type87contains88  integer(8) pure function f1(x, y)89    class(t1), intent(in) :: x90    integer, intent(in) :: y91  end92  integer(8) pure function f2(x, y)93    class(t1), intent(in) :: x94    class(t2), intent(in) :: y95  end96  subroutine test1(x, y, a)97    class(t1) :: x98    integer :: y99    real :: a(x + y)100  end101  ! Resolve to operator in parent class102  subroutine test2(x, y, a)103    class(t2) :: x104    integer :: y105    real :: a(x + y)106  end107  ! 2nd arg is passed object108  subroutine test3(x, y, a)109    class(t1) :: x110    class(t2) :: y111    real :: a(x + y)112  end113end114!Expect: m2.mod115!module m2116! type :: t1117! contains118!  procedure, pass(x) :: p1 => f1119!  generic :: operator(+) => p1120! end type121! type, extends(t1) :: t2122! contains123!  procedure, pass(y) :: p2 => f2124!  generic :: operator(+) => p2125! end type126!contains127! pure function f1(x, y)128!  class(t1), intent(in) :: x129!  integer(4), intent(in) :: y130!  integer(8) :: f1131! end132! pure function f2(x, y)133!  class(t1), intent(in) :: x134!  class(t2), intent(in) :: y135!  integer(8) :: f2136! end137! subroutine test1(x, y, a)138!  class(t1) :: x139!  integer(4) :: y140!  real(4) :: a(1_8:x%p1(y))141! end142! subroutine test2(x, y, a)143!  class(t2) :: x144!  integer(4) :: y145!  real(4) :: a(1_8:x%p1(y))146! end147! subroutine test3(x, y, a)148!  class(t1) :: x149!  class(t2) :: y150!  real(4) :: a(1_8:y%p2(x))151! end152!end153 154module m3155  type :: t1156  contains157    procedure, pass(x) :: p1 => f1158    procedure :: p3 => f3159    generic :: operator(.binary.) => p1160    generic :: operator(.unary.) => p3161  end type162  type, extends(t1) :: t2163  contains164    procedure, pass(y) :: p2 => f2165    generic :: operator(.binary.) => p2166  end type167contains168  integer(8) pure function f1(x, y)169    class(t1), intent(in) :: x170    integer, intent(in) :: y171  end172  integer(8) pure function f2(x, y)173    class(t1), intent(in) :: x174    class(t2), intent(in) :: y175  end176  integer(8) pure function f3(x)177    class(t1), intent(in) :: x178  end179  subroutine test1(x, y, a)180    class(t1) :: x181    integer :: y182    real :: a(x .binary. y)183  end184  ! Resolve to operator in parent class185  subroutine test2(x, y, a)186    class(t2) :: x187    integer :: y188    real :: a(x .binary. y)189  end190  ! 2nd arg is passed object191  subroutine test3(x, y, a)192    class(t1) :: x193    class(t2) :: y194    real :: a(x .binary. y)195  end196  subroutine test4(x, y, a)197    class(t1) :: x198    class(t2) :: y199    real :: a(.unary. x + .unary. y)200  end201end202!Expect: m3.mod203!module m3204!  type::t1205!  contains206!    procedure,pass(x)::p1=>f1207!    procedure::p3=>f3208!    generic::operator(.binary.)=>p1209!    generic::operator(.unary.)=>p3210!  end type211!  type,extends(t1)::t2212!  contains213!    procedure,pass(y)::p2=>f2214!    generic::operator(.binary.)=>p2215!  end type216!contains217!  pure function f1(x,y)218!    class(t1),intent(in)::x219!    integer(4),intent(in)::y220!    integer(8)::f1221!  end222!  pure function f2(x,y)223!    class(t1),intent(in)::x224!    class(t2),intent(in)::y225!    integer(8)::f2226!  end227!  pure function f3(x)228!    class(t1),intent(in)::x229!    integer(8)::f3230!  end231!  subroutine test1(x,y,a)232!    class(t1)::x233!    integer(4)::y234!    real(4)::a(1_8:x%p1(y))235!  end236!  subroutine test2(x,y,a)237!    class(t2)::x238!    integer(4)::y239!    real(4)::a(1_8:x%p1(y))240!  end241!  subroutine test3(x,y,a)242!    class(t1)::x243!    class(t2)::y244!    real(4)::a(1_8:y%p2(x))245!  end246!  subroutine test4(x,y,a)247!    class(t1)::x248!    class(t2)::y249!    real(4)::a(1_8:x%p3()+y%p3())250!  end251!end252