1! { dg-do compile }
2!
3! PR fortran/55827
4! gfortran used to ICE with the call to `tostring' depending on how the
5! `tostring' symbol was USE-associated.
6!
7! Contributed by Lorenz Hüdepohl <bugs@stellardeath.org>
8
9module stringutils
10  interface
11    pure function strlen(handle) result(len)
12      integer, intent(in) :: handle
13      integer :: len
14    end function
15  end interface
16end module
17module intermediate ! does not die if this module is merged with stringutils
18  contains
19  function tostring(handle) result(string)
20    use stringutils
21    integer, intent(in) :: handle
22    character(len=strlen(handle)) :: string
23  end function
24end module
25module usage
26  contains
27  subroutine dies_here(handle)
28    use stringutils ! does not die if this unnecessary line is omitted or placed after "use intermediate"
29    use intermediate
30    integer :: handle
31    write(*,*) tostring(handle) ! ICE
32  end subroutine
33end module
34
35
36