Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / allocate07.f90
blob8ebdbaa94cdd724a93e248991918db3f35c9b956
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Check for semantic errors in ALLOCATE statements
4 subroutine C936(param_ca_4_assumed, param_ta_4_assumed, param_ca_4_deferred)
5 ! If type-spec appears, the kind type parameter values of each
6 ! allocate-object shall be the same as the corresponding type
7 ! parameter values of the type-spec.
9 real(kind=4), allocatable :: x1, x2(:)
11 type WithParam(k1, l1)
12 integer, kind :: k1=1
13 integer, len :: l1=2
14 end type
16 type, extends(WithParam) :: WithParamExtent(k2, l2)
17 integer, kind :: k2
18 integer, len :: l2
19 end type
21 type, extends(WithParamExtent) :: WithParamExtent2(k3, l3)
22 integer, kind :: k3 = 8
23 integer, len :: l3
24 end type
26 type(WithParam(4, 2)), allocatable :: param_ta_4_2
27 class(WithParam(4, 2)), pointer :: param_ca_4_2
29 type(WithParam(4, *)), pointer :: param_ta_4_assumed
30 class(WithParam(4, *)), allocatable :: param_ca_4_assumed
32 type(WithParam(4, :)), allocatable :: param_ta_4_deferred
33 class(WithParam(4, :)), pointer :: param_ca_4_deferred
34 class(WithParam), allocatable :: param_defaulted
36 type(WithParamExtent2(k1=4, l1=:, k2=5, l2=:, l3=8 )), pointer :: extended2
38 class(*), pointer :: whatever
40 ! Nominal test cases
41 allocate(real(kind=4):: x1, x2(10))
42 allocate(WithParam(4, 2):: param_ta_4_2, param_ca_4_2)
43 allocate(WithParamExtent(4, 2, 8, 3):: param_ca_4_2)
44 allocate(WithParam(4, *):: param_ta_4_assumed, param_ca_4_assumed)
45 allocate(WithParamExtent(4, *, 8, 3):: param_ca_4_assumed)
46 allocate(WithParam(4, 2):: param_ta_4_deferred, param_ca_4_deferred)
47 allocate(WithParamExtent(4, 2, 8, 3):: param_ca_4_deferred)
48 allocate(WithParamExtent2(k1=4, l1=5, k2=5, l2=6, l3=8 ):: extended2)
49 allocate(WithParamExtent2(k1=4, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_ca_4_2)
50 allocate(WithParam:: param_defaulted)
51 allocate(WithParam(k1=1, l1=2):: param_defaulted)
52 allocate(WithParam(k1=1):: param_defaulted)
53 allocate(WithParamExtent2(k1=1, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_defaulted)
54 allocate(WithParamExtent2(k1=1, l1=2, k2=5, l2=6, k3=5, l3=8 ):: whatever)
57 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
58 allocate(real(kind=8):: x1)
59 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
60 allocate(real(kind=8):: x2(10))
61 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
62 allocate(WithParam(8, 2):: param_ta_4_2)
63 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
64 allocate(WithParam(8, 2):: param_ca_4_2)
65 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
66 allocate(WithParamExtent(8, 2, 8, 3):: param_ca_4_2)
67 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
68 allocate(WithParam(8, *):: param_ta_4_assumed)
69 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
70 allocate(WithParam(8, *):: param_ca_4_assumed)
71 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
72 allocate(WithParamExtent(8, *, 8, 3):: param_ca_4_assumed)
73 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
74 allocate(WithParam(8, 2):: param_ta_4_deferred)
75 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
76 allocate(WithParam(8, 2):: param_ca_4_deferred)
77 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
78 allocate(WithParamExtent(8, 2, 8, 3):: param_ca_4_deferred)
79 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
80 allocate(WithParamExtent2(k1=5, l1=5, k2=5, l2=6, l3=8 ):: extended2)
81 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
82 allocate(WithParamExtent2(k1=5, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_ca_4_2)
83 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
84 allocate(WithParamExtent2(k1=4, l1=5, k2=5, l2=6, k3=5, l3=8 ):: extended2)
85 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
86 allocate(WithParam:: param_ca_4_2)
87 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
88 allocate(WithParam(k1=2, l1=2):: param_defaulted)
89 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
90 allocate(WithParam(k1=2):: param_defaulted)
91 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
92 allocate(WithParamExtent2(k1=5, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_defaulted)
93 end subroutine