This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran] SELECT TYPE via ASSOCIATE
> It's a variation of the original test case, and produces:
> [sfilippo@donald bug20]$ ./bug20_dx
> ?Dynamic type on entry: XBASE
> ?Not implemented yet
> ?Dynamic type CLASS DEFAULT clause: DBASE
>
> which is pure nonsense :-)
I think this is not connected to Daniel's patch. I get the same output
on the following modified test case (with patched and unpatched
trunk). I will look into it ...
Cheers,
Janus
module base_mat_mod
type :: base_sparse_mat
contains
procedure, pass(a) :: get_fmt => base_get_fmt
end type base_sparse_mat
contains
function base_get_fmt(a) result(res)
implicit none
class(base_sparse_mat), intent(in) :: a
character(len=5) :: res
res = 'NULL'
end function base_get_fmt
end module base_mat_mod
module d_base_mat_mod
use base_mat_mod
type, extends(base_sparse_mat) :: d_base_sparse_mat
integer, allocatable :: v(:)
contains
procedure, pass(a) :: get_fmt => d_base_get_fmt
end type d_base_sparse_mat
type, extends(d_base_sparse_mat) :: x_base_sparse_mat
contains
procedure, pass(a) :: get_fmt => x_base_get_fmt
end type x_base_sparse_mat
contains
function d_base_get_fmt(a) result(res)
implicit none
class(d_base_sparse_mat), intent(in) :: a
character(len=5) :: res
res = 'DBASE'
end function d_base_get_fmt
function x_base_get_fmt(a) result(res)
implicit none
class(x_base_sparse_mat), intent(in) :: a
character(len=5) :: res
res = 'XBASE'
end function x_base_get_fmt
end module d_base_mat_mod
program bug20
use d_base_mat_mod
class(d_base_sparse_mat), allocatable :: a
integer, parameter :: nv=10
integer :: i
character(len=8) :: string
allocate(x_base_sparse_mat :: a)
allocate(a%v(nv))
a%v(:) = (/ (i, i=1,nv) /)
string=a%get_fmt()
write(0,*) 'Dynamic type on entry: ',string
select type(a)
type is (d_base_sparse_mat)
write(0,*) 'NV = ',size(a%v)
string=a%get_fmt()
write(0,*) 'Dynamic type TYPE IS clause: ',string
class default
write(0,*) 'Not implemented yet '
string=a%get_fmt()
write(0,*) 'Dynamic type CLASS DEFAULT clause: ',string
end select
end program bug20