1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Check for semantic errors in ALLOCATE statements
6 ! If type-spec appears, it shall specify a type with which each
7 ! allocate-object is type compatible.
14 real, allocatable
:: x(:)
22 class(A
), allocatable
:: polymorph
23 type(A
), allocatable
:: notpolymorph
26 real, allocatable
:: x1
, x2(:)
27 class(A
), allocatable
:: aa1
, aa2(:)
28 class(B
), pointer :: bp1
, bp2(:)
29 class(C
), allocatable
:: ca1
, ca2(:)
30 class(*), pointer :: up1
, up2(:)
31 type(A
), allocatable
:: npaa1
, npaa2(:)
32 type(B
), pointer :: npbp1
, npbp2(:)
33 type(C
), allocatable
:: npca1
, npca2(:)
34 class(Unrelated
), allocatable
:: unrelat
37 allocate(real:: x2(2))
38 allocate(real:: bp2(3)%x(5))
39 !OK, type-compatible with A
40 allocate(A
:: aa1
, aa2(2), up1
, up2(3), &
41 unrelat
%polymorph
, unrelat
%notpolymorph
, npaa1
, npaa2(4))
42 !OK, type compatible with B
43 allocate(B
:: aa1
, aa2(2), up1
, up2(3), &
44 unrelat
%polymorph
, bp1
, bp2(2), npbp1
, npbp2(2:4))
45 !OK, type compatible with C
46 allocate(C
:: aa1
, aa2(2), up1
, up2(3), &
47 unrelat
%polymorph
, bp1
, bp2(2), ca1
, ca2(4), &
51 !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
52 allocate(complex:: x1
)
53 !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
54 allocate(complex:: x2(2))
55 !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
56 allocate(logical:: bp2(3)%x(5))
57 !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
59 !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
60 allocate(B
:: unrelat
%notpolymorph
)
61 !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
63 !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
64 allocate(B
:: npaa2(4))
65 !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
66 allocate(C
:: npca1
, bp1
, npbp1
)