2010-11-30 Tobias Burnus <burnus@net-b.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / proc_ptr_11.f90
blob4e8b3c2531428260593f190478212cfad78165fa
1 ! { dg-do compile }
3 ! PR 38290: Procedure pointer assignment checking.
5 ! Test case found at http://de.wikibooks.org/wiki/Fortran:_Fortran_2003:_Zeiger
6 ! Adapted by Janus Weil <janus@gcc.gnu.org>
8 program bsp
9 implicit none
11 abstract interface
12 subroutine up()
13 end subroutine up
14 end interface
16 procedure( up ) , pointer :: pptr
17 procedure(isign), pointer :: q
19 procedure(iabs),pointer :: p1
20 procedure(f), pointer :: p2
22 pointer :: p3
23 interface
24 function p3(x)
25 real(8) :: p3,x
26 intent(in) :: x
27 end function p3
28 end interface
30 pptr => add ! { dg-error "is not a subroutine" }
32 q => add
34 print *, pptr() ! { dg-error "is not a function" }
36 p1 => iabs
37 p2 => iabs
38 p1 => f
39 p2 => f
40 p2 => p1
41 p1 => p2
43 p1 => abs ! { dg-error "Type/kind mismatch in return value" }
44 p2 => abs ! { dg-error "Type/kind mismatch in return value" }
46 p3 => dsin
47 p3 => sin ! { dg-error "Type/kind mismatch in return value" }
49 contains
51 function add( a, b )
52 integer :: add
53 integer, intent( in ) :: a, b
54 add = a + b
55 end function add
57 integer function f(x)
58 integer,intent(in) :: x
59 f = 317 + x
60 end function
62 end program bsp