Debian Codegraph @

gcc/testsuite/gfortran.dg/pointer_check_15.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-O -fcheck=pointer -fdump-tree-original" }
3 !
4 ! PR fortran/121145
5 ! Erroneous runtime error: Proc-pointer actual argument 'ptr' is not associated
6 !
7 ! Contributed by Federico Perini.
8
9 module m
10 implicit none
11
12 abstract interface
13 subroutine fun(x)
14 real, intent(in) :: x
15 end subroutine fun
16 end interface
17
18 contains
19
20 subroutine with_fun(sub)
21 procedure(fun), optional :: sub
22 if (present(sub)) stop 1
23 end subroutine
24
25 subroutine with_non_optional(sub)
26 procedure(fun) :: sub
27 end subroutine
28
29 end module m
30
31 program p
32 use m
33 implicit none
34
35 procedure(fun), pointer :: ptr1 => null()
36 procedure(fun), pointer :: ptr2 => null()
37
38 call with_fun()
39 call with_fun(sub=ptr1) ! no runtime check here
40
41 if (associated (ptr2)) then
42 call with_non_optional(sub=ptr2) ! runtime check here
43 end if
44 end
45
46 ! { dg-final { scan-tree-dump-times "Proc-pointer actual argument .'ptr2.'" 1 "original" } }