brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.5 KiB · 94e17f3 Raw
104 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Check for semantic errors in ALLOCATE statements3 4subroutine C936(param_ca_4_assumed, param_ta_4_assumed, param_ca_4_deferred)5! If type-spec appears, the kind type parameter values of each6! allocate-object shall be the same as the corresponding type7! parameter values of the type-spec.8 9  real(kind=4), allocatable :: x1, x2(:)10 11  type WithParam(k1, l1)12    integer, kind :: k1=113    integer, len :: l1=214  end type15 16  type, extends(WithParam) :: WithParamExtent(k2, l2)17    integer, kind :: k218    integer, len :: l219  end type20 21  type, extends(WithParamExtent) :: WithParamExtent2(k3, l3)22    integer, kind :: k3 = 823    integer, len :: l324  end type25 26  type(WithParam(4, 2)), allocatable :: param_ta_4_227  class(WithParam(4, 2)), pointer :: param_ca_4_228 29  type(WithParam(4, *)), pointer :: param_ta_4_assumed30  class(WithParam(4, *)), allocatable :: param_ca_4_assumed31 32  type(WithParam(4, :)), allocatable :: param_ta_4_deferred33  class(WithParam(4, :)), pointer :: param_ca_4_deferred34  class(WithParam), allocatable :: param_defaulted35 36  type(WithParamExtent2(k1=4, l1=:, k2=5, l2=:, l3=8 )), pointer :: extended237 38  class(*), pointer :: whatever39 40  character(:), allocatable :: deferredChar41  character(2), allocatable :: char242 43  ! Nominal test cases44  allocate(real(kind=4):: x1, x2(10))45  allocate(WithParam(4, 2):: param_ta_4_2, param_ca_4_2)46  allocate(WithParamExtent(4, 2, 8, 3):: param_ca_4_2)47  allocate(WithParam(4, *):: param_ta_4_assumed, param_ca_4_assumed)48  allocate(WithParamExtent(4, *, 8, 3):: param_ca_4_assumed)49  allocate(WithParam(4, 2):: param_ta_4_deferred, param_ca_4_deferred)50  allocate(WithParamExtent(4, 2, 8, 3):: param_ca_4_deferred)51  allocate(WithParamExtent2(k1=4, l1=5, k2=5, l2=6, l3=8 ):: extended2)52  allocate(WithParamExtent2(k1=4, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_ca_4_2)53  allocate(WithParam:: param_defaulted)54  allocate(WithParam(k1=1, l1=2):: param_defaulted)55  allocate(WithParam(k1=1):: param_defaulted)56  allocate(WithParamExtent2(k1=1, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_defaulted)57  allocate(WithParamExtent2(k1=1, l1=2, k2=5, l2=6, k3=5, l3=8 ):: whatever)58  allocate(character(len=1):: deferredChar)59  allocate(character(len=2):: char2)60 61  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec62  allocate(real(kind=8):: x1)63  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec64  allocate(real(kind=8):: x2(10))65  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec66  allocate(WithParam(8, 2):: param_ta_4_2)67  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec68  allocate(WithParam(8, 2):: param_ca_4_2)69  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec70  allocate(WithParamExtent(8, 2, 8, 3):: param_ca_4_2)71  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec72  allocate(WithParam(8, *):: param_ta_4_assumed)73  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec74  allocate(WithParam(8, *):: param_ca_4_assumed)75  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec76  allocate(WithParamExtent(8, *, 8, 3):: param_ca_4_assumed)77  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec78  allocate(WithParam(8, 2):: param_ta_4_deferred)79  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec80  allocate(WithParam(8, 2):: param_ca_4_deferred)81  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec82  allocate(WithParamExtent(8, 2, 8, 3):: param_ca_4_deferred)83  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec84  allocate(WithParamExtent2(k1=5, l1=5, k2=5, l2=6, l3=8 ):: extended2)85  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec86  allocate(WithParamExtent2(k1=5, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_ca_4_2)87  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec88  allocate(WithParamExtent2(k1=4, l1=5, k2=5, l2=6, k3=5, l3=8 ):: extended2)89  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec90  allocate(WithParam:: param_ca_4_2)91  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec92  allocate(WithParam(k1=2, l1=2):: param_defaulted)93  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec94  allocate(WithParam(k1=2):: param_defaulted)95  !ERROR: Type parameters of allocatable object in ALLOCATE must be the same as the corresponding ones in type-spec96  allocate(WithParamExtent2(k1=5, l1=2, k2=5, l2=6, k3=5, l3=8 ):: param_defaulted)97 98  !ERROR: Either type-spec or source-expr must appear in ALLOCATE when allocatable object has a deferred type parameters99  allocate(deferredChar)100  !ERROR: Character length of allocatable object in ALLOCATE must be the same as the type-spec101  allocate(character(len=1):: char2)102 103end subroutine104