brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 8b07025 Raw
106 lines · plain
1! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s2 3! Check the analyzed form of a defined operator or assignment.4 5! Type-bound defined assignment6module m17  type :: t8  contains9    procedure :: b1 => s110    procedure, pass(y) :: b2 => s211    generic :: assignment(=) => b1, b212  end type13contains14  subroutine s1(x, y)15    class(t), intent(out) :: x16    integer, intent(in), value :: y17  end18  subroutine s2(x, y)19    real, intent(out) :: x20    class(t), intent(in) :: y21  end22  subroutine test1(x)23    type(t) :: x24    real :: a25    integer :: j26    !CHECK: CALL s1(x,1_4)27    x = 128    j = 129    !CHECK: CALL s1(x,j)30    x = j ! no parentheses due to VALUE31    !CHECK: CALL s2(a,(x))32    a = x33  end34  subroutine test2(x)35    class(t) :: x36    real :: a37    !CHECK: CALL x%b1(1_4)38    x = 139    !CHECK: CALL (x)%b2(a)40    a = x41  end42end43 44! Type-bound operator45module m246  type :: t247  contains48    procedure, pass(x2) :: b2 => f49    generic :: operator(+) => b250  end type51contains52  integer pure function f(x1, x2)53    class(t2), intent(in) :: x154    class(t2), intent(in) :: x255  end56  subroutine test2(x, y)57    class(t2) :: x58    type(t2) :: y59    !CHECK: i=f(x,y)60    i = x + y61    !CHECK: i=x%b2(y)62    i = y + x63  end64end module65 66! Non-type-bound assignment and operator67module m368  type t69  end type70  interface assignment(=)71    subroutine s1(x, y)72      import73      class(t), intent(out) :: x74      integer, intent(in) :: y75    end76    subroutine s2(x, y)77      real, intent(out) :: x78      class(*), intent(in) :: y79    end80    subroutine s3(x, y)81      integer, intent(out) :: x82      class(*), intent(in), value :: y83    end84  end interface85  interface operator(+)86    integer function f(x, y)87      import88      class(t), intent(in) :: x, y89    end90  end interface91contains92  subroutine test(x, y, z)93    class(t) :: x, y94    class(*), intent(in) :: z95    real :: a96    !CHECK: CALL s1(x,2_4)97    x = 298    !CHECK: i=f(x,y)99    i = x + y100    !CHECK: CALL s2(a,(z))101    a = z102    !CHECK: CALL s3(i,z)103    i = z104  end105end106