1! { dg-do link }
2!
3! PR fortran/52729
4!
5! Based on a contribution of Andrew Benson
6!
7module testMod
8  type testType
9  end type testType
10contains
11  subroutine testSub()
12    implicit none
13    procedure(double precision ), pointer :: r
14    class    (testType         ), pointer :: testObject
15    double precision                      :: testVal
16
17    ! Failed as testFunc was BT_UNKNOWN
18    select type (testObject)
19    class is (testType)
20       testVal=testFunc()
21       r => testFunc
22    end select
23    return
24  end subroutine testSub
25
26  double precision function testFunc()
27    implicit none
28    return
29  end function testFunc
30end module testMod
31
32module testMod2
33  implicit none
34contains
35  subroutine testSub()
36    procedure(double precision ), pointer :: r
37    double precision                      :: testVal
38    ! Failed as testFunc was BT_UNKNOWN
39    block
40      r => testFunc
41      testVal=testFunc()
42    end block
43  end subroutine testSub
44
45  double precision function testFunc()
46  end function testFunc
47end module testMod2
48
49module m3
50  implicit none
51contains
52  subroutine my_test()
53    procedure(sub), pointer :: ptr
54    ! Before the fix, one had the link error
55    ! "undefined reference to `sub.1909'"
56    block
57      ptr => sub
58      call sub()
59    end block
60  end subroutine my_test
61  subroutine sub(a)
62    integer, optional :: a
63  end subroutine sub
64end module m3
65
66end
67