aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/short_circuiting_3.f90
blob: 069f3f80b947bd9ae59a9d74df286f9af9d08b2a (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 "-O3" }
!
! PR 57160: short-circuit IF only with -ffrontend-optimize
!
! this checks that short-circuiting is done with -O3
!
! 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 /= 1) stop 1

contains

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

end