summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/char_result_7.f90
blob: 7b8692f403eaf0d9cbb05afa33d3b685f739763e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
! Related to PR 15326.  Try calling string functions whose lengths depend
! on a dummy procedure.
! { dg-do run }
integer pure function double (x)
  integer, intent (in) :: x
  double = x * 2
end function double

program main
  implicit none

  interface
    integer pure function double (x)
      integer, intent (in) :: x
    end function double
  end interface

  call test (f1 (double, 100), 200)

  call indirect (double)
contains
  function f1 (fn, i)
    integer :: i
    interface
      integer pure function fn (x)
        integer, intent (in) :: x
      end function fn
    end interface
    character (len = fn (i)) :: f1
    f1 = ''
  end function f1

  subroutine indirect (fn)
    interface
      integer pure function fn (x)
        integer, intent (in) :: x
      end function fn
    end interface
    call test (f1 (fn, 100), 200)
  end subroutine indirect

  subroutine test (string, length)
    character (len = *) :: string
    integer, intent (in) :: length
    if (len (string) .ne. length) call abort
  end subroutine test
end program main