GENERIC type-boound procedures

Salvatore Filippone salvatore.filippone@uniroma2.it
Fri Sep 19 15:52:00 GMT 2008


Subject says (almost) all: are they supposed to work? 

If yes, what's wrong with the attached code? 

Note that the same code without the generic works (invoking the
appropriate specific) 
 
Thanks
Salvatore

----------------- gen-type-bound.f03 -----------
module bar_mod

  type foo
    integer :: i
    
  contains
    procedure, pass(a) :: foo_v => foo_v_inner    
    procedure, pass(a) :: foo_m => foo_m_inner    
    generic, public    :: foo => foo_v, foo_m
  end type foo
  
  private foo_v_inner, foo_m_inner

contains
  
  subroutine foo_v_inner(x,a)
    real :: x(:)
    type(foo) :: a
    
    a%i = int(x(1))
  end subroutine foo_v_inner
  
  subroutine foo_m_inner(x,a)
    real :: x(:,:)
    type(foo) :: a
    
    a%i = int(x(1,1))
  end subroutine foo_m_inner
end module bar_mod

program foobar
  use bar_mod
  type(foo) :: dat
  real :: x1(10), x2(10,10)

  x1=1
  x2=2
 
  call dat%foo(x1)
  call dat%foo(x2)

end program foobar
------------------------------- log --------------------
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/usr/local/gnutest
--with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.4.0 20080918 (experimental) (GCC) 
$  gfortran -c gen-type-bound.f03
gen-type-bound.f03:8.13:

    procedure, pass(a) :: foo_m => foo_m_inner    
            1
Warning: Polymorphic entities are not yet implemented, non-polymorphic
passed-object dummy argument of 'foo_m_inner' at (1) accepted
gen-type-bound.f03:7.13:

    procedure, pass(a) :: foo_v => foo_v_inner    
            1
Warning: Polymorphic entities are not yet implemented, non-polymorphic
passed-object dummy argument of 'foo_v_inner' at (1) accepted
gen-type-bound.f03:39.10:

  call dat%foo(x1)
         1
Error: Found no matching specific binding for the call to the GENERIC
'foo' at (1)
gen-type-bound.f03:40.10:

  call dat%foo(x2)
         1
Error: Found no matching specific binding for the call to the GENERIC
'foo' at (1)





More information about the Fortran mailing list