[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / allocate07.f90
bloba948765deb921eb835dcacb6a6cf9c2c39cb1ab4
1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
2 ! REQUIRES: shell
3 ! Check for semantic errors in ALLOCATE statements
5 subroutine C936(param_ca_4_assumed, param_ta_4_assumed, param_ca_4_deferred)
6 ! If type-spec appears, the kind type parameter values of each
7 ! allocate-object shall be the same as the corresponding type
8 ! parameter values of the type-spec.
10 real(kind=4), allocatable :: x1, x2(:)
12 type WithParam(k1, l1)
13 integer, kind :: k1=1
14 integer, len :: l1=2
15 end type
17 type, extends(WithParam) :: WithParamExtent(k2, l2)
18 integer, kind :: k2
19 integer, len :: l2
20 end type
22 type, extends(WithParamExtent) :: WithParamExtent2(k3, l3)
23 integer, kind :: k3 = 8
24 integer, len :: l3
25 end type
27 type(WithParam(4, 2)), allocatable :: param_ta_4_2
28 class(WithParam(4, 2)), pointer :: param_ca_4_2
30 type(WithParam(4, *)), pointer :: param_ta_4_assumed
31 class(WithParam(4, *)), allocatable :: param_ca_4_assumed
33 type(WithParam(4, :)), allocatable :: param_ta_4_deferred
34 class(WithParam(4, :)), pointer :: param_ca_4_deferred
35 class(WithParam), allocatable :: param_defaulted
37 type(WithParamExtent2(k1=4, l1=:, k2=5, l2=:, l3=8 )), pointer :: extended2
39 class(*), pointer :: whatever
41 ! Nominal test cases
42 allocate(real(kind=4):: x1, x2(10))
43 allocate(WithParam(4, 2):: param_ta_4_2, param_ca_4_2)
44 allocate(WithParamExtent(4, 2, 8, 3):: param_ca_4_2)
45 allocate(WithParam(4, *):: param_ta_4_assumed, param_ca_4_assumed)
46 allocate(WithParamExtent(4, *, 8, 3):: param_ca_4_assumed)
47 allocate(WithParam(4, 2):: param_ta_4_deferred, param_ca_4_deferred)
48 allocate(WithParamExtent(4, 2, 8, 3):: param_ca_4_deferred)
49 allocate(WithParamExtent2(k1=4, l1=5, k2=5, l2=6, l3=8 ):: extended2)
50 allocate(WithParamExtent2(k1=4, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_ca_4_2)
51 allocate(WithParam:: param_defaulted)
52 allocate(WithParam(k1=1, l1=2):: param_defaulted)
53 allocate(WithParam(k1=1):: param_defaulted)
54 allocate(WithParamExtent2(k1=1, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_defaulted)
55 allocate(WithParamExtent2(k1=1, l1=2, k2=5, l2=6, k3=5, l3=8 ):: whatever)
58 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
59 allocate(real(kind=8):: x1)
60 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
61 allocate(real(kind=8):: x2(10))
62 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
63 allocate(WithParam(8, 2):: param_ta_4_2)
64 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
65 allocate(WithParam(8, 2):: param_ca_4_2)
66 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
67 allocate(WithParamExtent(8, 2, 8, 3):: param_ca_4_2)
68 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
69 allocate(WithParam(8, *):: param_ta_4_assumed)
70 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
71 allocate(WithParam(8, *):: param_ca_4_assumed)
72 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
73 allocate(WithParamExtent(8, *, 8, 3):: param_ca_4_assumed)
74 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
75 allocate(WithParam(8, 2):: param_ta_4_deferred)
76 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
77 allocate(WithParam(8, 2):: param_ca_4_deferred)
78 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
79 allocate(WithParamExtent(8, 2, 8, 3):: param_ca_4_deferred)
80 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
81 allocate(WithParamExtent2(k1=5, l1=5, k2=5, l2=6, l3=8 ):: extended2)
82 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
83 allocate(WithParamExtent2(k1=5, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_ca_4_2)
84 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
85 allocate(WithParamExtent2(k1=4, l1=5, k2=5, l2=6, k3=5, l3=8 ):: extended2)
86 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
87 allocate(WithParam:: param_ca_4_2)
88 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
89 allocate(WithParam(k1=2, l1=2):: param_defaulted)
90 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
91 allocate(WithParam(k1=2):: param_defaulted)
92 !ERROR: Kind type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec
93 allocate(WithParamExtent2(k1=5, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_defaulted)
94 end subroutine