This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR41600 - [OOP] SELECT TYPE with associate-name => exp: Arrays not supported
- From: Paul Richard Thomas <paul dot richard dot thomas at gmail dot com>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: fortran at gcc dot gnu dot org, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 2 May 2012 09:50:11 +0200
- Subject: Re: [Patch, fortran] PR41600 - [OOP] SELECT TYPE with associate-name => exp: Arrays not supported
- References: <CAGkQGiKq=747mNY6JcxzOVDFFiQGZLhe_EfwSBTPSYfujaQR_A@mail.gmail.com> <4F665ED1.8000601@net-b.de> <CAGkQGi+e07=mdhL5jDFA4aQTi916YuSY5fdH2dFcZ6Yw3jDqww@mail.gmail.com> <4FA0C783.9010408@net-b.de>
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