Files
TheRock/compiler/amd-llvm/flang/test/Semantics/allocate05.f90
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

68 lines
2.2 KiB
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
! Check for semantic errors in ALLOCATE statements
subroutine C934()
! If type-spec appears, it shall specify a type with which each
! allocate-object is type compatible.
type A
integer i
end type
type, extends(A) :: B
real, allocatable :: x(:)
end type
type, extends(B) :: C
character(5) s
end type
type Unrelated
class(A), allocatable :: polymorph
type(A), allocatable :: notpolymorph
end type
real, allocatable :: x1, x2(:)
class(A), allocatable :: aa1, aa2(:)
class(B), pointer :: bp1, bp2(:)
class(C), allocatable :: ca1, ca2(:)
class(*), pointer :: up1, up2(:)
type(A), allocatable :: npaa1, npaa2(:)
type(B), pointer :: npbp1, npbp2(:)
type(C), allocatable :: npca1, npca2(:)
class(Unrelated), allocatable :: unrelat
allocate(real:: x1)
allocate(real:: x2(2))
allocate(real:: bp2(3)%x(5))
!OK, type-compatible with A
allocate(A:: aa1, aa2(2), up1, up2(3), &
unrelat%polymorph, unrelat%notpolymorph, npaa1, npaa2(4))
!OK, type compatible with B
allocate(B:: aa1, aa2(2), up1, up2(3), &
unrelat%polymorph, bp1, bp2(2), npbp1, npbp2(2:4))
!OK, type compatible with C
allocate(C:: aa1, aa2(2), up1, up2(3), &
unrelat%polymorph, bp1, bp2(2), ca1, ca2(4), &
npca1, npca2(2:4))
!ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
allocate(complex:: x1)
!ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
allocate(complex:: x2(2))
!ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
allocate(logical:: bp2(3)%x(5))
!ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
allocate(A:: unrelat)
!ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
allocate(B:: unrelat%notpolymorph)
!ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
allocate(B:: npaa1)
!ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
allocate(B:: npaa2(4))
!ERROR: Allocatable object in ALLOCATE must be type compatible with type-spec
allocate(C:: npca1, bp1, npbp1)
end subroutine