1! { dg-do compile } 2! { dg-options "-O2 -fdump-tree-optimized" } 3! Tests whether volatile really works for arrays 4! PR fortran/29601 5logical, allocatable, volatile :: t1(:) 6logical, allocatable :: t2(:) 7integer :: i 8 9allocate(t1(1),t2(1)) 10t1 = .false. 11t2 = .false. 12do i = 1, 2 13 if(ubound(t1,1) /= 1) print *, 'VolatileNotOptimizedAway1' 14 if(ubound(t2,1) /= 1) print *, 'NonVolatileNotOptimizedAway1' 15end do 16 17t1 = .false. 18if(t1(1)) print *, 'VolatileNotOptimizedAway2' 19t2 = .false. 20if(t2(1)) print *, 'NonVolatileNotOptimizedAway2' 21end 22! { dg-final { scan-tree-dump "VolatileNotOptimizedAway1" "optimized" } } 23! { dg-final { scan-tree-dump "VolatileNotOptimizedAway2" "optimized" } } 24! { dg-final { scan-tree-dump-not "NonVolatileNotOptimizedAway1" "optimized" } } 25! { dg-final { scan-tree-dump-not "NonVolatileNotOptimizedAway2" "optimized" } } 26