summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/short_circuiting_2.f90
blob: 765c8e736c55740ecb1e23ebb6c59303cb581d2a (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
! { dg-do run }
! { dg-options "-O0" }
!
! PR 57160: short-circuit IF only with -ffrontend-optimize
!
! this checks that short-circuiting is not done with -O0
!
! Contributed by Janus Weil <janus@gcc.gnu.org>

program short_circuit

   integer, save :: i = 0
   logical :: flag

   flag = .false.
   flag = check() .and. flag
   flag = flag .and. check()

   if (i /= 2) stop 1

contains

   logical function check()
      i = i + 1
      check = .true.
   end function

end