aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/function_optimize_10.f90
blob: 8906934d1c745fb0987682e1f5e9aadb641505cd (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
48
49
50
51
52
53
54
55
56
57
! { dg-do run }
! PR 51858 - this used to generate wrong code.
! Original test case by Don Simons.

program main
  implicit none
  logical :: test1_ok
  logical :: test2_ok
  logical :: test3_ok
  character(len=1):: charq

  charq = 'c'
  
  test1_ok = .true.
  test2_ok = .false.
  if (charq .eq. ' ') then
     test1_ok = .false.
  else if ((my_ichar(charq).ge.97 .and. my_ichar(charq).le.103)) then
     test2_OK = .true.
  end if
  if ((.not. test1_ok) .or. (.not. test2_ok)) call abort

  test1_ok = .true.
  test2_ok = .true.
  test3_ok = .false.

  if (charq .eq. ' ') then
     test1_ok = .false.
  else if ((my_ichar(charq).lt.97 .or. my_ichar(charq).gt.103)) then
     test2_ok = .false.
  else if ((my_ichar(charq).ge.97 .and. my_ichar(charq).le.103)) then
     test3_ok = .true.
  end if
  if ((.not. test1_ok) .or. (.not. test2_ok) .or. (.not. test3_ok)) call abort

  test1_ok = .true.
  test2_ok = .true.
  test3_ok = .false.

  if (charq .eq. ' ') then
     test1_ok = .false.
  else if ((my_ichar(charq).lt.97 .or. my_ichar(charq).gt.103)) then
     test2_ok = .false.
  else
     test3_ok = .true.
  end if

  if ((.not. test1_ok) .or. (.not. test2_ok) .or. (.not. test3_ok)) call abort

contains
  pure function my_ichar(c)
    integer :: my_ichar
    character(len=1), intent(in) :: c
    my_ichar = ichar(c)
  end function my_ichar
end program main