gcc/fortran/
[official-gcc.git] / gcc / testsuite / gfortran.dg / coarray_38.f90
blob6fa0a65edfcd014dccbabc1ddfb1351e7eefd8d2
1 ! { dg-do compile }
2 ! { dg-options "-fcoarray=lib" }
4 ! Valid code - but currently not implemented for -fcoarray=lib; single okay
6 subroutine one
7 implicit none
8 type t
9 integer, allocatable :: a
10 integer :: b
11 end type t
12 type t2
13 type(t), allocatable :: caf2[:]
14 end type t2
15 type(t), save :: caf[*],x
16 type(t2) :: y
18 x = caf[4] ! { dg-error "Sorry, coindexed coarray at \\(1\\) with allocatable component is not yet supported" }
19 x%a = caf[4]%a ! { dg-error "Sorry, coindexed access to a pointer or allocatable component of the coindexed coarray at \\(1\\) is not yet supported" }
20 x%b = caf[4]%b ! OK
21 x = y%caf2[5] ! { dg-error "Sorry, coindexed coarray at \\(1\\) with allocatable component is not yet supported" }
22 x%a = y%caf2[4]%a ! { dg-error "Sorry, coindexed access to a pointer or allocatable component of the coindexed coarray at \\(1\\) is not yet supported" }
23 x%b = y%caf2[4]%b ! OK
24 end subroutine one
26 subroutine two
27 implicit none
28 type t
29 integer, pointer :: a
30 integer :: b
31 end type t
32 type t2
33 type(t), allocatable :: caf2[:]
34 end type t2
35 type(t), save :: caf[*],x
36 type(t2) :: y
38 x = caf[4] ! OK
39 x%a = caf[4]%a ! { dg-error "Sorry, coindexed access to a pointer or allocatable component of the coindexed coarray at \\(1\\) is not yet supported" }
40 x%b = caf[4]%b ! OK
41 x = y%caf2[5] ! OK
42 x%a = y%caf2[4]%a ! { dg-error "Sorry, coindexed access to a pointer or allocatable component of the coindexed coarray at \\(1\\) is not yet supported" }
43 x%b = y%caf2[4]%b ! OK
44 end subroutine two
46 subroutine three
47 implicit none
48 type t
49 integer :: b
50 end type t
51 type t2
52 type(t), allocatable :: caf2(:)[:]
53 end type t2
54 type(t), save :: caf(10)[*]
55 integer :: x(10)
56 type(t2) :: y
58 x(1) = caf(2)[4]%b ! OK
59 x(:) = caf(:)[4]%b ! { dg-error "Sorry, coindexed access at \\(1\\) to a scalar component with an array partref is not yet supported" }
61 x(1) = y%caf2(2)[4]%b ! OK
62 x(:) = y%caf2(:)[4]%b ! { dg-error "Sorry, coindexed access at \\(1\\) to a scalar component with an array partref is not yet supported" }
63 end subroutine three
65 subroutine four
66 implicit none
67 type t
68 integer, allocatable :: a
69 integer :: b
70 end type t
71 type t2
72 class(t), allocatable :: caf2[:]
73 end type t2
74 class(t), allocatable :: caf[:]
75 type(t) :: x
76 type(t2) :: y
78 !x = caf[4] ! Unsupported - and ICEs in resolve_ordinary_assign, cf. PR fortran/65397
79 x%a = caf[4]%a ! { dg-error "Sorry, coindexed access to a pointer or allocatable component of the coindexed coarray at \\(1\\) is not yet supported" }
80 x%b = caf[4]%b ! OK
81 !x = y%caf2[5] ! Unsupported - and ICEs in resolve_ordinary_assign, cf. PR fortran/65397
82 x%a = y%caf2[4]%a ! { dg-error "Sorry, coindexed access to a pointer or allocatable component of the coindexed coarray at \\(1\\) is not yet supported" }
83 x%b = y%caf2[4]%b ! OK
84 end subroutine four
86 subroutine five
87 implicit none
88 type t
89 integer, pointer :: a
90 integer :: b
91 end type t
92 type t2
93 class(t), allocatable :: caf2[:]
94 end type t2
95 class(t), save, allocatable :: caf[:]
96 type(t) :: x
97 type(t2) :: y
99 !x = caf[4] ! OK - but ICEs in resolve_ordinary_assign, cf. PR fortran/65397
100 x%a = caf[4]%a ! { dg-error "Sorry, coindexed access to a pointer or allocatable component of the coindexed coarray at \\(1\\) is not yet supported" }
101 x%b = caf[4]%b ! OK
102 !x = y%caf2[5] ! OK - but ICEs in resolve_ordinary_assign, cf. PR fortran/65397
103 x%a = y%caf2[4]%a ! { dg-error "Sorry, coindexed access to a pointer or allocatable component of the coindexed coarray at \\(1\\) is not yet supported" }
104 x%b = y%caf2[4]%b ! OK
105 end subroutine five
107 subroutine six
108 implicit none
109 type t
110 integer :: b
111 end type t
112 type t2
113 class(t), allocatable :: caf2(:)[:]
114 end type t2
115 class(t), save, allocatable :: caf(:)[:]
116 integer :: x(10)
117 type(t2) :: y
119 x(1) = caf(2)[4]%b ! OK
120 x(:) = caf(:)[4]%b ! { dg-error "Sorry, coindexed access at \\(1\\) to a scalar component with an array partref is not yet supported" }
122 x(1) = y%caf2(2)[4]%b ! OK
123 x(:) = y%caf2(:)[4]%b ! { dg-error "Sorry, coindexed access at \\(1\\) to a scalar component with an array partref is not yet supported" }
124 end subroutine six