This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR58793 - Wrong value for _vtab for intrinsic types with CLASS(*): storage_size of class(*) gives wrong result
- From: Tobias Burnus <burnus at net-b dot de>
- To: Paul Richard Thomas <paul dot richard dot thomas at gmail dot com>, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 21 Oct 2013 11:20:54 +0200
- Subject: Re: [Patch, fortran] PR58793 - Wrong value for _vtab for intrinsic types with CLASS(*): storage_size of class(*) gives wrong result
- Authentication-results: sourceware.org; auth=none
- References: <CAGkQGiKRNeh8tGAp74CEF_1SL0uwQOc6mZ4SBLL46f-yLFzhDg at mail dot gmail dot com>
Paul Richard Thomas wrote:
This patch is fairly obvious and follows a suggestion from Tobias to
use gfc_element_size. He even wrote the testcase!
Bootstrapped and regested on FC17/x86_64 - OK for trunk?
Looks good to me. Thanks for the patch.
PS In writing this, I have just noted that I need to trap ts->type ==
BT_HOLLERITH. It would be a rather bizarre thing to try to do but I
just know that somebody, somewhere will eventually try it :-) Consider
that it will be done in the committed version.
I think that should be done as follow-up patch.In particular, it is not
obvious how it should be handled.
The program below ICEs in gfc_typenode_for_spec;with both Intel's and
Cray's compiler, it gives
Character with len 3
Something else
I somehow had expected that it maps to a character.
program test
call up("abc")
call up(3habc)
contains
subroutine up(x)
class(*) :: x
select type(x)
type is (character(*))
print *, 'Character with len', len(x)
class default
print *, 'Something else'
end select
end subroutine
end program test
The following - related to TYPE(*) - is also accepted, but I think it
shouldn't. (call up(x) is presumably invalid). It fails here at
assembler time.
program test
use iso_c_binding
integer,target ::aa
call up(c_loc(aa)) ! Probably okay but not matchable?
call bar(aa) !OK
contains
subroutine up(x)
class(*) :: x
select type(x)
! type is (c_ptr) ! invalid & rejected by gfortran
! print *, 'C_ptr'
class default
print *, 'Something else'
end select
end subroutine
subroutine bar(x)
type(*) :: x
call up(x) ! Invalid
end subroutine bar
end program test
Tobias
2013-10-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran 57893
* class.c : Include target-memory.h.
(gfc_find_intrinsic_vtab) Build a minimal expression so that
gfc_element_size can be used to obtain the storage size, rather
that the kind value.
2013-10-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran 57893
* gfortran.dg/unlimited_polymorphic_12.f90 : New test.