Debian Codegraph @

gcc/testsuite/gfortran.dg/interface_abstract_6.f90

raw
1 ! { dg-do compile }
2 ! { dg-options "-fdump-tree-original" }
3 !
4 ! PR fortran/122206
5 !
6 ! Verify that procedure interfaces are "stable"
7
8 module test_example
9 use, intrinsic :: iso_c_binding, only: c_double, c_int
10 implicit none
11
12 abstract interface
13 function simple_interface(iarg1, arg2) bind(c) result(res)
14 import c_double, c_int
15 integer(c_int), value, intent(in) :: iarg1
16 real(c_double), value, intent(in) :: arg2
17 real(c_double) :: res
18 end function simple_interface
19 end interface
20
21 procedure(simple_interface), bind(c,name="simple_function") :: simple_function
22
23 interface
24 function other_interface(iarg1, arg2) result(res)
25 import c_double, c_int
26 integer(c_int), value, intent(in) :: iarg1
27 real(c_double), value, intent(in) :: arg2
28 real(c_double) :: res
29 end function other_interface
30 end interface
31
32 procedure(other_interface) :: other_function
33
34 contains
35 subroutine test_example_interface
36 implicit none
37 integer(c_int) :: iarg1 = 2
38 real(c_double) :: arg2 = 10.
39 real(c_double) :: val1, val2
40
41 val1 = simple_function(iarg1, arg2)
42 val2 = simple_function(iarg1, arg2)
43 if (val1 /= val2) stop 1
44
45 val1 = other_function(iarg1, arg2)
46 val2 = other_function(iarg1, arg2)
47 if (val1 /= val2) stop 2
48
49 end subroutine test_example_interface
50 end module test_example
51
52 ! { dg-final { scan-tree-dump-times "simple_function \\(iarg1, arg2\\);" 2 "original"} }
53 ! { dg-final { scan-tree-dump-times "other_function \\(iarg1, arg2\\);" 2 "original"} }