brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · eca6c9a Raw
68 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Check for semantic errors in ALLOCATE statements3 4 5subroutine C934()6! If type-spec appears, it shall specify a type with which each7! allocate-object is type compatible.8 9  type A10    integer i11  end type12 13  type, extends(A) :: B14    real, allocatable :: x(:)15  end type16 17  type, extends(B) :: C18    character(5) s19  end type20 21  type Unrelated22    class(A), allocatable :: polymorph23    type(A), allocatable :: notpolymorph24  end type25 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 :: unrelat35 36  allocate(real:: x1)37  allocate(real:: x2(2))38  allocate(real:: bp2(3)%x(5))39  !OK, type-compatible with A40  allocate(A:: aa1, aa2(2), up1, up2(3), &41    unrelat%polymorph, unrelat%notpolymorph, npaa1, npaa2(4))42  !OK, type compatible with B43  allocate(B:: aa1, aa2(2), up1, up2(3), &44    unrelat%polymorph, bp1, bp2(2), npbp1, npbp2(2:4))45  !OK, type compatible with C46  allocate(C:: aa1, aa2(2), up1, up2(3), &47    unrelat%polymorph, bp1, bp2(2), ca1, ca2(4), &48    npca1, npca2(2:4))49 50 51  !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec52  allocate(complex:: x1)53  !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec54  allocate(complex:: x2(2))55  !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec56  allocate(logical:: bp2(3)%x(5))57  !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec58  allocate(A:: unrelat)59  !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec60  allocate(B:: unrelat%notpolymorph)61  !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec62  allocate(B:: npaa1)63  !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec64  allocate(B:: npaa2(4))65  !ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec66  allocate(C:: npca1, bp1, npbp1)67end subroutine68