brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · e866dd8 Raw
140 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! More coarray error tests.3module m14  integer :: local[*] ! ok in module5end6program main7  use iso_fortran_env8  !ERROR: Coarray 'namedconst' may not be a named constant9  !ERROR: Local coarray must have the SAVE or ALLOCATABLE attribute10  integer, parameter :: namedConst = 12311  codimension namedConst[*]12  !ERROR: Coarray 'coarr1' may not be in COMMON block '//'13  real :: coarr1[*]14  common//coarr115  !ERROR: Variable 'event' with EVENT_TYPE or LOCK_TYPE must be a coarray16  type(event_type) event17  !ERROR: Variable 'lock' with EVENT_TYPE or LOCK_TYPE must be a coarray18  type(lock_type) lock19  !ERROR: Variable 'notify' with NOTIFY_TYPE must be a coarray20  type(notify_type) notify21  integer :: local[*] ! ok in main22end23 24function func1()25  !ERROR: Function result may not be a coarray26  integer :: func1[*]27  !ERROR: Local coarray must have the SAVE or ALLOCATABLE attribute28  integer :: local[*]29  integer, save :: saved[*] ! ok30  integer :: inited[*] = 1 ! ok31  func = 132end33 34function func2()35  type t36    real, allocatable :: comp[:]37  end type38  type t239    !ERROR: Allocatable or array component 'allo' may not have a coarray ultimate component '%comp'40    type(t), allocatable :: allo41    !ERROR: Allocatable or array component 'arr' may not have a coarray ultimate component '%comp'42    type(t) :: arr(1)43  end type44  !ERROR: Function result 'func2' may not have a coarray potential component '%comp'45  type(t) func246  !ERROR: Pointer 'ptr' may not have a coarray potential component '%comp'47  type(t), pointer :: ptr48  !ERROR: Coarray 'coarr' may not have a coarray potential component '%comp'49  type(t), save :: coarr[*]50  !ERROR: Local variable 'local' without the SAVE or ALLOCATABLE attribute may not have a coarray potential subobject component '%comp'51  type(t) :: local52end53 54module m255  type t056    integer n57  end type58  type t159    class(t0), allocatable :: a60  end type61  type t262    type(t1) c63  end type64 contains65  subroutine test(x)66    type(t2), intent(in) :: x[*]67    !ERROR: The base of a polymorphic object may not be coindexed68    call sub1(x[1]%c%a)69    !ERROR: A coindexed designator may not have a type with the polymorphic potential subobject component '%a'70    call sub2(x[1]%c)71  end72  subroutine sub1(x)73    type(t0), intent(in) :: x74  end75  subroutine sub2(x)76    type(t1), intent(in) :: x77  end78end79 80module m381  type t82    real, allocatable :: a(:)83    real, pointer :: p(:)84    real arr(2)85  end type86 contains87  subroutine sub(ca)88    real, intent(in) :: ca(:)[*]89  end90  subroutine test(cat)91    type(t), intent(in) :: cat[*]92    call sub(cat%arr(1:2)) ! ok93    !ERROR: Actual argument associated with coarray dummy argument 'ca=' must be a coarray94    call sub(cat%arr([1]))95    !ERROR: Actual argument associated with coarray dummy argument 'ca=' must be a coarray96    call sub(cat%a)97    !ERROR: Actual argument associated with coarray dummy argument 'ca=' must be a coarray98    call sub(cat%p)99  end100end101 102subroutine s4103  type t104    real, allocatable :: a(:)[:]105  end type106  type t2107    !ERROR: Allocatable or array component 'bad1' may not have a coarray ultimate component '%a'108    type(t), allocatable :: bad1109    !ERROR: Pointer 'bad2' may not have a coarray potential component '%a'110    type(t), pointer :: bad2111    !ERROR: Allocatable or array component 'bad3' may not have a coarray ultimate component '%a'112    type(t) :: bad3(2)113    !ERROR: Component 'bad4' is a coarray and must have the ALLOCATABLE attribute and have a deferred coshape114    !ERROR: Coarray 'bad4' may not have a coarray potential component '%a'115    type(t) :: bad4[*]116  end type117  type(t), save :: ta(2)118  !ERROR: 'a' has corank 1, but coindexed reference has 2 cosubscripts119  print *, ta(1)%a(1)[1,2]120  !ERROR: An allocatable or pointer component reference must be applied to a scalar base121  print *, ta(:)%a(1)[1]122  !ERROR: Subscripts must appear in a coindexed reference when its base is an array123  print *, ta(1)%a[1]124end125 126subroutine s5(a, notify, res)127  use iso_fortran_env128  type t129    type(notify_type) :: a130  end type131  real, intent(in) :: a[*]132  type(event_type), intent(in) :: notify[*]133  !ERROR: An INTENT(OUT) dummy argument may not be, or contain, NOTIFY_TYPE134  type(notify_type), intent(out) :: res[*]135  !ERROR: Variable 'bad' with NOTIFY_TYPE potential component '%a' must be a coarray136  type(t) :: bad137  !ERROR: NOTIFY= specifier must have type NOTIFY_TYPE from ISO_FORTRAN_ENV138  print *, a[1, NOTIFY=notify]139end140