GENERIC type-boound procedures
Daniel Kraft
d@domob.eu
Fri Sep 19 16:30:00 GMT 2008
Salvatore Filippone wrote:
> Subject says (almost) all: are they supposed to work?
>
> If yes, what's wrong with the attached code?
Yes, they are. However, the checks for resolving a generic procedure
(and for ambiguity) are not yet working fully, see PR 37297.
Regarding your code, that seems not to be the problem, however... I've
not looked at it thoroughly and am not sure if it is legal, but I don't
see why it shouldn't be, on a quick read-through. You may want to file
a bug report.
Thanks,
Daniel
> ----------------- 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)
--
Done: Arc-Bar-Cav-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
To go: Hea-Kni-Mon-Pri-Ran-Rog-Tou
More information about the Fortran
mailing list