This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] PR41600 - [OOP] SELECT TYPE with associate-name => exp: Arrays not supported


Dear Tobias,

Thanks for completing the review.  I should be able to commit tonight.

> Thanks for the patch. I think it is OK.
>
> Regarding:
>
>> ! ? ? ? if (ref&& ?ref->type != REF_ARRAY&& ?seen_array)
>> ! ? ? ? {
>> ! ? ? ? ? gfc_error ("CLASS selector at %L is an array with CLASS "
>> ! ? ? ? ? ? ? ? ? ? ?"components; this is not allowed since the "
>> ! ? ? ? ? ? ? ? ? ? ?"elements could have different dynamic types",
>> ! ? ? ? ? ? ? ? &target->where);
>
>
> Could you open a PR for it? If possible with a test case.

select_type_28.f03 is that testcase (see below).  I am not sure what
the PR would be for - surely such selectors make no logical sense?
Oddly I can see no such restriction in the standard. Indeed, there
seems to me to be an identical diffculty with pointer assignment.
Maybe a message to clf would be in order?

Cheers

Paul

Cheers

Paul

  implicit none
  type t0
    integer :: j = 42
  end type t0
  type, extends(t0) :: t1
    integer :: k = 99
  end type t1
  type t
    integer :: i
    class(t0), allocatable :: foo
  end type t
  type(t) :: m(4)
  integer :: n

  do n = 1, 2
    allocate(m(n)%foo, source = t0(n*99))
  end do
  do n = 3, 4
    allocate(m(n)%foo, source = t1(n*99, n*999))
  end do

! The class components 'foo' of m(1:2) now have a different dynamic
type to those of m(3:4)

! An array of objects with ultimate class components cannot be a selector
! since each element could have a different dynamic type.

  select type(bar => m%foo) ! { dg-error "is an array with CLASS components" }
    type is(t0)
      if (any (bar%j .ne. [99, 198, 297, 396])) call abort
    type is(t1)
      call abort
  end select

end


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]