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] PR58793 - Wrong value for _vtab for intrinsic types with CLASS(*): storage_size of class(*) gives wrong result


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.


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