Files
TheRock/compiler/amd-llvm/flang/test/Semantics/allocate04.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

80 lines
2.7 KiB
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
! Check for semantic errors in ALLOCATE statements
subroutine C933_b(n)
! If any allocate-object has a deferred type parameter, is unlimited polymorphic,
! or is of abstract type, either type-spec or source-expr shall appear.
! only testing unlimited polymorphic and abstract-type here
type, abstract :: Base
integer x
end type
type, extends(Base) :: A
integer y
end type
type, extends(Base) :: B
class(Base), allocatable :: y
end type
type C
class(*), pointer :: whatever
real, pointer :: y
end type
integer n
class(*), allocatable :: u1, u2(:)
class(C), allocatable :: n1, n2(:)
class(Base), pointer :: p1, p2(:)
class(B), pointer :: p3, p4(:)
type(A) :: molda = A(1, 2)
!ERROR: Either type-spec or source-expr must appear in ALLOCATE when allocatable object is unlimited polymorphic
allocate(u1)
!ERROR: Either type-spec or source-expr must appear in ALLOCATE when allocatable object is unlimited polymorphic
allocate(u2(2))
!ERROR: Either type-spec or source-expr must appear in ALLOCATE when allocatable object is unlimited polymorphic
allocate(n1%whatever)
!ERROR: Either type-spec or source-expr must appear in ALLOCATE when allocatable object is unlimited polymorphic
allocate(n2(2)%whatever)
!ERROR: Either type-spec or source-expr must appear in ALLOCATE when allocatable object is of abstract type
allocate(p1)
!ERROR: Either type-spec or source-expr must appear in ALLOCATE when allocatable object is of abstract type
allocate(p2(2))
!ERROR: Either type-spec or source-expr must appear in ALLOCATE when allocatable object is of abstract type
allocate(p3%y)
!ERROR: Either type-spec or source-expr must appear in ALLOCATE when allocatable object is of abstract type
allocate(p4(2)%y)
!WRONG allocate(Base:: u1)
! No error expected
allocate(real:: u1, u2(2))
allocate(A:: u1, u2(2))
allocate(C:: u1, u2(2))
allocate(character(n):: u1, u2(2))
allocate(C:: n1%whatever, n2(2)%whatever)
allocate(A:: p1, p2(2))
allocate(B:: p3%y, p4(2)%y)
allocate(u1, u2(2), MOLD = cos(5.+n))
allocate(u1, u2(2), MOLD = molda)
allocate(u1, u2(2), MOLD = n1)
allocate(u1, u2(2), MOLD = new_line(a="a"))
allocate(n1%whatever, MOLD = n2(1))
allocate(p1, p2(2), MOLD = p3)
allocate(p3%y, p4(2)%y, MOLD = B(5))
allocate(u1, u2(2), SOURCE = cos(5.+n))
allocate(u1, u2(2), SOURCE = molda)
allocate(u1, u2(2), SOURCE = n1)
allocate(u1, u2(2), SOURCE = new_line("a"))
allocate(n1%whatever, SOURCE = n2(1))
allocate(p1, p2(2), SOURCE = p3)
allocate(p3%y, p4(2)%y, SOURCE = B(5))
! OK, not unlimited polymorphic or abstract
allocate(n1, n2(2))
allocate(p3, p4(2))
end subroutine