PR target/83368
[official-gcc.git] / gcc / testsuite / gfortran.dg / coarray_22.f90
blob7860c3030dfb28bb90586e4119f1a3c2a5a480cc
1 ! { dg-do compile }
2 ! { dg-options "-fcoarray=single" }
4 ! Constraint checks for invalid access of remote pointers
5 ! (Accessing the value is ok, checking/changing association
6 ! status is invalid)
8 ! PR fortran/18918
10 type t
11 integer, pointer :: ptr => null()
12 end type t
13 type(t) :: x[*], y[*]
15 if (associated(x%ptr)) stop 0
16 if (associated(x%ptr,y%ptr)) stop 0
18 if (associated(x[1]%ptr)) stop 0 ! { dg-error "shall not be coindexed" }
19 if (associated(x%ptr,y[1]%ptr)) stop 0 ! { dg-error "shall not be coindexed" }
21 nullify (x%ptr)
22 nullify (x[1]%ptr) ! { dg-error "shall not be coindexed" }
24 x%ptr => null(x%ptr)
25 x%ptr => null(x[1]%ptr) ! { dg-error "shall not be coindexed" }
26 x[1]%ptr => null(x%ptr) ! { dg-error "shall not have a coindex" }
28 allocate(x%ptr)
29 deallocate(x%ptr)
31 allocate(x[1]%ptr) ! { dg-error "Coindexed allocatable object" }
32 deallocate(x[1]%ptr) ! { dg-error "Coindexed allocatable object" }
33 end