Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/gfortran.dg/short_circuiting.f90 @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 84e7813d76e9 |
children |
line wrap: on
line source
! { dg-do compile } ! { dg-additional-options "-Wextra" } ! ! PR 85599: warn about short-circuiting of logical expressions for non-pure functions ! ! Contributed by Janus Weil <janus@gcc.gnu.org> module a interface impl_pure_a module procedure impl_pure_a1 end interface contains logical function impl_pure_a1() impl_pure_a1 = .true. end function end module program short_circuit use a logical :: flag flag = .false. flag = check() .and. flag flag = flag .and. check() ! { dg-warning "might not be evaluated" } flag = flag .and. pure_check() flag = flag .and. impl_pure_1() flag = flag .and. impl_pure_2() flag = flag .and. impl_pure_a1() flag = flag .and. impl_pure_a() contains logical function check() integer, save :: i = 1 print *, "check", i i = i + 1 check = .true. end function logical pure function pure_check() pure_check = .true. end function logical function impl_pure_1() impl_pure_1 = .true. end function logical function impl_pure_2() impl_pure_2 = impl_pure_1() end function end