2008-07-06 Kai Tietz <kai.tietz@onevision.com>
[official-gcc.git] / gcc / testsuite / gfortran.dg / module_interface_1.f90
blob54ea14bcae2f1749029c437f6b4bbfe463250a57
1 ! { dg-do run }
2 ! This tests the fix for PR16940, module interfaces to
3 ! contained functions caused ICEs.
4 ! This is a simplified version of the example in the PR
5 ! discussion, which was due to L.Meissner.
7 ! Submitted by Paul Thomas pault@gcc.gnu.org
9 module Max_Loc_Mod
10 implicit none
11 interface Max_Location
12 module procedure I_Max_Loc
13 end interface
14 contains
15 function I_Max_Loc (Vector) result(Ans)
16 integer, intent (in), dimension(:) :: Vector
17 integer, dimension(1) :: Ans
18 Ans = maxloc(Vector)
19 return
20 end function I_Max_Loc
21 end module Max_Loc_Mod
22 program module_interface
23 use Max_Loc_Mod
24 implicit none
25 integer :: Vector (7)
26 Vector = (/1,6,3,5,19,1,2/)
27 call Selection_Sort (Vector)
28 contains
29 subroutine Selection_Sort (Unsorted)
30 integer, intent (in), dimension(:) :: Unsorted
31 integer, dimension (1) :: N
32 N = Max_Location (Unsorted)
33 if (N(1).ne.5) call abort ()
34 return
35 end subroutine Selection_Sort
36 end program module_interface
38 ! { dg-final { cleanup-modules "max_loc_mod" } }