summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/substr_5.f90
blob: fb409ead9522a0711a35437947d35b5df063f0f9 (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
! { dg-do run }
!
  character(*), parameter  :: chrs = '-+.0123456789eEdD'
  character(*), parameter  :: expr = '-+.0123456789eEdD'
  integer :: i

  if (index(chrs(:), expr) /= 1) call abort
  if (index(chrs(14:), expr) /= 0) call abort
  if (index(chrs(:12), expr) /= 0) call abort
  if (index(chrs, expr(:)) /= 1) call abort
  if (index(chrs, expr(1:)) /= 1) call abort
  if (index(chrs, expr(:1)) /= 1) call abort

  if (foo(expr) /= 1) call abort
  if (foo(expr) /= 1) call abort
  if (foo(expr) /= 1) call abort
  if (foo(expr(:)) /= 1) call abort
  if (foo(expr(1:)) /= 1) call abort
  if (foo(expr(:1)) /= 1) call abort

  call bar(expr)

contains
  subroutine bar(expr)
    character(*), intent(in) :: expr
    character(*), parameter  :: chrs = '-+.0123456789eEdD'
    integer :: foo

    if (index(chrs(:), expr) /= 1) call abort
    if (index(chrs(14:), expr) /= 0) call abort
    if (index(chrs(:12), expr) /= 0) call abort
    if (index(chrs, expr(:)) /= 1) call abort
    if (index(chrs, expr(1:)) /= 1) call abort
    if (index(chrs, expr(:1)) /= 1) call abort
  end subroutine bar

  integer function foo(expr)
    character(*), intent(in) :: expr
    character(*), parameter  :: chrs = '-+.0123456789eEdD'

    foo = index(chrs, expr)
  end function foo

end