view gcc/testsuite/gfortran.dg/short_circuiting_3.f90 @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
line wrap: on
line source

! { 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