1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
3 ! Check for semantic errors in ALLOCATE statements
5 module not_iso_fortran_env
13 ! If SOURCE= appears, the declared type of source-expr shall not be EVENT_TYPE
14 ! or LOCK_-TYPE from the intrinsic module ISO_FORTRAN_ENV, or have a potential subobject
15 ! component of type EVENT_TYPE or LOCK_TYPE.
19 type(event_type
), pointer :: event
20 type(lock_type
), pointer :: lock
24 class(oktype1
), allocatable
:: t1a
28 type, extends(oktype1
) :: oktype3
29 real, allocatable
:: x(:)
33 type(event_type
), allocatable
:: event
37 type(event_type
) :: event
41 type(lock_type
), allocatable
:: lock
45 type(lock_type
) :: lock
48 type, extends(noktype4
) :: noktype5
49 real, allocatable
:: x(:)
52 type, extends(event_type
) :: noktype6
53 real, allocatable
:: x(:)
58 type(recursiveType
), allocatable
:: next
63 type(recursiveType
), allocatable
:: next
64 type(noktype5
), allocatable
:: trouble
67 ! variable with event_type or lock_type have to be coarrays
69 type(oktype1
), allocatable
:: okt1
[:]
70 class(oktype2
), allocatable
:: okt2(:)[:]
71 type(oktype3
), allocatable
:: okt3
[:]
72 type(noktype1
), allocatable
:: nokt1
[:]
73 type(noktype2
), allocatable
:: nokt2
[:]
74 class(noktype3
), allocatable
:: nokt3
[:]
75 type(noktype4
), allocatable
:: nokt4
[:]
76 type(noktype5
), allocatable
:: nokt5
[:]
77 class(noktype6
), allocatable
:: nokt6(:)[:]
78 type(event_type
), allocatable
:: event
[:]
79 type(lock_type
), allocatable
:: lock(:)[:]
80 class(recursiveType
), allocatable
:: recok
81 type(recursiveTypeNok
), allocatable
:: recnok
[:]
82 class(*), allocatable
:: whatever
[:]
84 type(oktype1
), allocatable
:: okt1src
[:]
85 class(oktype2
), allocatable
:: okt2src(:)[:]
86 type(oktype3
), allocatable
:: okt3src
[:]
87 class(noktype1
), allocatable
:: nokt1src
[:]
88 type(noktype2
), allocatable
:: nokt2src
[:]
89 type(noktype3
), allocatable
:: nokt3src
[:]
90 class(noktype4
), allocatable
:: nokt4src
[:]
91 type(noktype5
), allocatable
:: nokt5src
[:]
92 class(noktype6
), allocatable
:: nokt6src(:)[:]
93 type(event_type
), allocatable
:: eventsrc
[:]
94 type(lock_type
), allocatable
:: locksrc(:)[:]
95 type(recursiveType
), allocatable
:: recoksrc
96 class(recursiveTypeNok
), allocatable
:: recnoksrc
[:]
99 allocate(okt1
[*], SOURCE
=okt1src
)
100 allocate(okt2
[*], SOURCE
=okt2src
)
101 allocate(okt3
[*], SOURCE
=okt3src
)
102 allocate(whatever
[*], SOURCE
=okt3src
)
103 allocate(recok
, SOURCE
=recoksrc
)
110 allocate(nokt6(10)[*])
111 allocate(lock(10)[*])
115 allocate(nokt1
[*], MOLD
=nokt1src
)
116 allocate(nokt2
[*], MOLD
=nokt2src
)
117 allocate(nokt3
[*], MOLD
=nokt3src
)
118 allocate(nokt4
[*], MOLD
=nokt4src
)
119 allocate(nokt5
[*], MOLD
=nokt5src
)
120 allocate(nokt6
[*], MOLD
=nokt6src
)
121 allocate(lock
[*], MOLD
=locksrc
)
122 allocate(event
[*], MOLD
=eventsrc
)
123 allocate(recnok
[*],MOLD
=recnoksrc
)
124 allocate(whatever
[*],MOLD
=nokt6src
)
126 !ERROR: SOURCE expression type must not have potential subobject component of type EVENT_TYPE or LOCK_TYPE from ISO_FORTRAN_ENV
127 allocate(nokt1
[*], SOURCE
=nokt1src
)
128 !ERROR: SOURCE expression type must not have potential subobject component of type EVENT_TYPE or LOCK_TYPE from ISO_FORTRAN_ENV
129 allocate(nokt2
[*], SOURCE
=nokt2src
)
130 !ERROR: SOURCE expression type must not have potential subobject component of type EVENT_TYPE or LOCK_TYPE from ISO_FORTRAN_ENV
131 allocate(nokt3
[*], SOURCE
=nokt3src
)
132 !ERROR: SOURCE expression type must not have potential subobject component of type EVENT_TYPE or LOCK_TYPE from ISO_FORTRAN_ENV
133 allocate(nokt4
[*], SOURCE
=nokt4src
)
134 !ERROR: SOURCE expression type must not have potential subobject component of type EVENT_TYPE or LOCK_TYPE from ISO_FORTRAN_ENV
135 allocate(nokt5
[*], SOURCE
=nokt5src
)
136 !ERROR: SOURCE expression type must not have potential subobject component of type EVENT_TYPE or LOCK_TYPE from ISO_FORTRAN_ENV
137 allocate(nokt6
[*], SOURCE
=nokt6src
)
138 !ERROR: SOURCE expression type must not be EVENT_TYPE or LOCK_TYPE from ISO_FORTRAN_ENV
139 allocate(lock
[*], SOURCE
=locksrc
)
140 !ERROR: SOURCE expression type must not be EVENT_TYPE or LOCK_TYPE from ISO_FORTRAN_ENV
141 allocate(event
[*], SOURCE
=eventsrc
)
142 !ERROR: SOURCE expression type must not have potential subobject component of type EVENT_TYPE or LOCK_TYPE from ISO_FORTRAN_ENV
143 allocate(recnok
[*],SOURCE
=recnoksrc
)
144 !ERROR: SOURCE expression type must not have potential subobject component of type EVENT_TYPE or LOCK_TYPE from ISO_FORTRAN_ENV
145 allocate(whatever
[*],SOURCE
=nokt5src
)
150 use not_iso_fortran_env
!type restriction do not apply
153 type(event_type
), allocatable
:: event
157 type(lock_type
) :: lock
160 type(oktype1
), allocatable
:: okt1
[:]
161 class(oktype2
), allocatable
:: okt2
[:]
162 type(event_type
), allocatable
:: team
[:]
163 class(lock_type
), allocatable
:: lock
[:]
165 type(oktype1
), allocatable
:: okt1src
[:]
166 class(oktype2
), allocatable
:: okt2src
[:]
167 class(event_type
), allocatable
:: teamsrc
[:]
168 type(lock_type
), allocatable
:: locksrc
[:]
170 allocate(okt1
[*], SOURCE
=okt1src
)
171 allocate(okt2
[*], SOURCE
=okt2src
)
172 allocate(team
[*], SOURCE
=teamsrc
)
173 allocate(lock
[*], SOURCE
=locksrc
)