1! { dg-do compile }
2! Tests the fix for PR31630, in which the association of the argument
3! of 'cmp' did not work.
4!
5! Contributed by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
6!
7module box_module
8  type box
9    integer :: m = 0
10  end type box
11end module box_module
12
13module sort_box_module
14contains
15
16  subroutine heapsort_box(cmp)
17    interface
18       subroutine cmp(a)
19         use box_module
20         type(box) :: a
21       end subroutine cmp
22    end interface
23    optional :: cmp
24  end subroutine heapsort_box
25
26end module sort_box_module
27
28
29module boxarray_module
30  use box_module
31  implicit none
32
33  type boxarray
34    type(box), allocatable :: bxs(:)
35  end type boxarray
36contains
37
38  subroutine boxarray_build_l(ba)
39    type(boxarray) :: ba
40    allocate(ba%bxs(1))
41  end subroutine boxarray_build_l
42
43  subroutine boxarray_sort()
44    use sort_box_module
45    call heapsort_box
46  end subroutine boxarray_sort
47
48end module boxarray_module
49