brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · acc4701 Raw
107 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Test that user-defined assignment is used in the right places3 4module m15  type t16  end type7  type t28  end type9  interface assignment(=)10    subroutine assign_il(x, y)11      integer, intent(out) :: x12      logical, intent(in) :: y13    end14    subroutine assign_li(x, y)15      logical, intent(out) :: x16      integer, intent(in) :: y17    end18    subroutine assign_tt(x, y)19      import t120      type(t1), intent(out) :: x21      type(t1), intent(in) :: y22    end23    subroutine assign_tz(x, y)24      import t125      type(t1), intent(out) :: x26      complex, intent(in) :: y27    end28    subroutine assign_01(x, y)29      real, intent(out) :: x30      real, intent(in) :: y(:)31    end32  end interface33contains34  ! These are all intrinsic assignments35  pure subroutine test1()36    type(t2) :: a, b, b5(5)37    logical :: l38    integer :: i, i5(5)39    a = b40    b5 = a41    l = .true.42    i = z'1234'43    i5 = 1.044  end45 46  ! These have invalid type combinations47  subroutine test2()48    type(t1) :: a49    type(t2) :: b50    logical :: l, l5(5)51    complex :: z, z5(5), z55(5,5)52    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(t1) and TYPE(t2)53    a = b54    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types REAL(4) and LOGICAL(4)55    r = l56    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types LOGICAL(4) and REAL(4)57    l = r58    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(t1) and REAL(4)59    a = r60    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(t2) and COMPLEX(4)61    b = z62    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar COMPLEX(4) and rank 1 array of COMPLEX(4)63    z = z564    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches rank 1 array of LOGICAL(4) and scalar COMPLEX(4)65    l5 = z66    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches rank 1 array of COMPLEX(4) and rank 2 array of COMPLEX(4)67    z5 = z5568  end69 70  ! These should all be defined assignments. Because the subroutines71  ! implementing them are not pure, they should all produce errors72  pure subroutine test3()73    type(t1) :: a, b74    integer :: i75    logical :: l76    complex :: z77    real :: r, r5(5)78    !ERROR: Procedure 'assign_tt' referenced in pure subprogram 'test3' must be pure too79    a = b80    !ERROR: Procedure 'assign_il' referenced in pure subprogram 'test3' must be pure too81    i = l82    !ERROR: Procedure 'assign_li' referenced in pure subprogram 'test3' must be pure too83    l = i84    !ERROR: Procedure 'assign_il' referenced in pure subprogram 'test3' must be pure too85    i = .true.86    !ERROR: Procedure 'assign_tz' referenced in pure subprogram 'test3' must be pure too87    a = z88    !ERROR: Procedure 'assign_01' referenced in pure subprogram 'test3' must be pure too89    r = r590  end91 92  ! Like test3 but not in a pure subroutine so no errors.93  subroutine test4()94    type(t1) :: a, b95    integer :: i96    logical :: l97    complex :: z98    real :: r, r5(5)99    a = b100    i = l101    l = i102    i = .true.103    a = z104    r = r5105  end106end107