tree-optimization/113385 - wrong loop father with early exit vectorization
[official-gcc.git] / gcc / testsuite / gfortran.dg / proc_ptr_comp_1.f90
blob5e53ee4e44dbbe0a8e12b86cbaa2df5d5505a7e9
1 ! { dg-do run }
3 ! PR39630: Fortran 2003: Procedure pointer components.
5 ! Basic test for PPCs with SUBROUTINE interface and NOPASS.
7 ! Contributed by Janus Weil <janus@gcc.gnu.org>
9 type t
10 integer :: i
11 procedure(sub), pointer, nopass :: ppc
12 procedure(), pointer, nopass :: proc
13 end type
15 type, extends(t) :: t2
16 procedure(), pointer, nopass :: proc2
17 end type t2
19 type(t) :: x
20 type(t2) :: x2
22 procedure(sub),pointer :: pp
23 integer :: sum = 0
25 x%i = 1
26 x%ppc => sub
27 pp => x%ppc
29 call sub(1)
30 if (sum/=1) STOP 1
31 call pp(2)
32 if (sum/=3) STOP 2
33 call x%ppc(3)
34 if (sum/=6) STOP 3
36 ! calling object as argument
37 x%proc => sub2
38 call x%proc(x)
39 if (x%i/=7) STOP 4
41 ! type extension
42 x%proc => sub
43 call x%proc(4)
44 if (sum/=10) STOP 5
45 x2%proc => sub
46 call x2%proc(5)
47 if (sum/=15) STOP 6
48 x2%proc2 => sub
49 call x2%proc2(6)
50 if (sum/=21) STOP 7
52 contains
54 subroutine sub(y)
55 integer, intent(in) :: y
56 sum = sum + y
57 end subroutine
59 subroutine sub2(arg)
60 type(t),intent(inout) :: arg
61 arg%i = arg%i + sum
62 end subroutine
64 end