brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · a2eddaf Raw
76 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Tests for the ALLOCATED() intrinsic3subroutine alloc(coarray_alloc, coarray_not_alloc, t2_not_alloc, &4                 assumedRank)5 6  interface7    function return_allocatable()8      integer, allocatable :: return_allocatable(:)9    end function10  end interface11 12  type :: t113    integer, allocatable :: alloc(:)14    integer :: not_alloc15  end type16 17  type :: t218    real, allocatable :: coarray_alloc[:]19    real, allocatable :: coarray_alloc_array(:)[:]20  end type21 22 23  integer :: not_alloc(100)24  real, allocatable :: x_alloc25  character(:), allocatable :: char_alloc(:)26  type(t1) :: dt_not_alloc(100)27  type(t1), allocatable :: dt_alloc(:)28 29  real, allocatable :: coarray_alloc[:, :]30  real, allocatable :: coarray_alloc_array(:)[:, :]31  real :: coarray_not_alloc(:)[*]32 33  type(t2) :: t2_not_alloc34  real, allocatable :: assumedRank(..)35 36 37  ! OK38  print *, allocated(x_alloc)39  print *, allocated(char_alloc)40  print *, allocated(dt_alloc)41  print *, allocated(dt_not_alloc(3)%alloc)42  print *, allocated(dt_alloc(3)%alloc)43  print *, allocated(coarray_alloc)44  print *, allocated(coarray_alloc[2,3])45  print *, allocated(t2_not_alloc%coarray_alloc)46  print *, allocated(t2_not_alloc%coarray_alloc[2])47  print *, allocated(assumedRank)48  select rank (assumedRank)49  rank (0)50    print *, allocated(scalar=assumedRank)51  rank default52    print *, allocated(array=assumedRank)53  end select54 55  !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component56  print *, allocated(not_alloc)57  !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component58  print *, allocated(dt_not_alloc)59  !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component60  print *, allocated(dt_alloc%not_alloc)61  !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component62  print *, allocated(char_alloc(:))63  !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component64  print *, allocated(char_alloc(1)(1:10))65  !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component66  print *, allocated(coarray_alloc_array(1:10))67  !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component68  print *, allocated(coarray_alloc_array(1:10)[2,2])69  !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component70  print *, allocated(t2_not_alloc%coarray_alloc_array(1))71  !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component72  print *, allocated(t2_not_alloc%coarray_alloc_array(1)[2])73  !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component74  print *, allocated(return_allocatable())75end subroutine76