URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gfortran.dg/] [dynamic_dispatch_8.f03] - Rev 694
Compare with Previous | Blame | View Log
! { dg-do run }!! PR 41829: [OOP] Runtime error with dynamic dispatching. Tests! dynamic dispatch in a case where the caller knows nothing about! the dynamic type at compile time.!! Contributed by Salvatore Filippone <sfilippone@uniroma2.it>!module foo_modtype foointeger :: icontainsprocedure, pass(a) :: doitprocedure, pass(a) :: getitend type fooprivate doit,getitcontainssubroutine doit(a)class(foo) :: aa%i = 1! write(*,*) 'FOO%DOIT base version'end subroutine doitfunction getit(a) result(res)class(foo) :: ainteger :: resres = a%iend function getitend module foo_modmodule foo2_moduse foo_modtype, extends(foo) :: foo2integer :: jcontainsprocedure, pass(a) :: doit => doit2procedure, pass(a) :: getit => getit2end type foo2private doit2, getit2containssubroutine doit2(a)class(foo2) :: aa%i = 2a%j = 3! write(*,*) 'FOO2%DOIT derived version'end subroutine doit2function getit2(a) result(res)class(foo2) :: ainteger :: resres = a%jend function getit2end module foo2_modmodule bar_moduse foo_modtype barclass(foo), allocatable :: acontainsprocedure, pass(a) :: doitprocedure, pass(a) :: getitend type barprivate doit,getitcontainssubroutine doit(a)class(bar) :: acall a%a%doit()end subroutine doitfunction getit(a) result(res)class(bar) :: ainteger :: resres = a%a%getit()end function getitend module bar_modprogram testd10use foo_moduse foo2_moduse bar_modtype(bar) :: aallocate(foo :: a%a)call a%doit()! write(*,*) 'Getit value : ', a%getit()if (a%getit() .ne. 1) call abortdeallocate(a%a)allocate(foo2 :: a%a)call a%doit()! write(*,*) 'Getit value : ', a%getit()if (a%getit() .ne. 3) call abortend program testd10! { dg-final { cleanup-modules "foo_mod foo2_mod bar_mod" } }
