Peter Klausler bbc27fbb1c
[flang] Refine checks on assignments to coarrays (#129966)
F'2023 10.2.1.2 paragraph 2 imposes some requirements on the left-hand
sides of assignments when they have coindices, and one was not checked
while another was inaccurately checked. In short, intrinsic assignment
to a coindexed object can't change its type, and neither can it affect
allocatable components.
2025-03-10 13:19:39 -07:00

19 lines
575 B
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
! 10.2.1.2p1(1)
program test
class(*), allocatable :: pa
class(*), pointer :: pp
class(*), allocatable :: pac[:]
type t
real, allocatable :: a
end type
type(t) auc[*]
pa = 1 ! ok
!ERROR: Left-hand side of assignment may not be polymorphic unless assignment is to an entire allocatable
pp = 1
!ERROR: Left-hand side of assignment may not be polymorphic if it is a coarray
pac = 1
!ERROR: Left-hand side of assignment must not be coindexed due to allocatable ultimate component '%a'
auc[1] = t()
end