[patch, fortran] Implement VOLATILE statement/attribute (PR 29601)

FX Coudert fxcoudert@gmail.com
Tue Nov 7 11:53:00 GMT 2006


> 2006-11-06  Tobias Burnus  <burnus@net-b.de>
>
>     fortran/29601
>     * symbol.c (check_conflict, gfc_add_volatile): Add volatile  
> support.
>     * decl.c (match_attr_spec, gfc_match_volatile): Add volatile  
> support.
>     * gfortran.h (symbol_attribute): Add volatile_ to struct.
>     * resolve.c (was_declared): Add volatile support.
>     * trans-decl.c (gfc_finish_var_decl): Add volatile support.
>     * match.h: Declare gfc_match_volatile.
>     * parse.c (decode_statement): Recognize volatile.
>     * modules.c (ab_attribute, attr_bits, mio_symbol_attribute):
>       Add volatile support.
>     * dump-parse-tree.c (gfc_show_attr): Add volatile support.

OK. The only question I have is if you made sure that your patch does  
the right thing for allocatable objects and pointers, where both  
allocation/association status as well as the actual content should be  
marked VOLATILE. I don't see it explicitly done in the patch, and in  
these cases the volatile qualification does not appear in the tree  
dump, but the tests I made looked like it works ok (but it's hard to  
say, because the optimizer is not clever enough for all cases, anyway :)

Also, if the answer to the previous question is "it's fine", could  
you please add the two following testcases, dealing with pointers and  
arrays, when you commit?


$ cat volatile7.f90
! { dg-do compile }
! { dg-options "-O2 -fdump-tree-optimized" }
! Tests whether volatile really works
! PR fortran/29601
logical, allocatable, volatile :: t1(:)
logical, allocatable :: t2(:)
integer :: i

allocate(t1(1),t2(1))
t1 = .false.
t2 = .false.
do i = 1, 2
   if(ubound(t1,1) /= 1) print *, 'VolatileNotOptimizedAway'
   if(ubound(t2,1) /= 1) print *, 'NonVolatileNotOptimizedAway'
end do
! The optimizer is not yet clever enough to do that ;-)
!do i = 1, 2
!  if(t1(1)) print *, 'VolatileNotOptimizedAway'
!  if(t2(1)) print *, 'NonVolatileNotOptimizedAway'
!end do
end
! { dg-final { scan-tree-dump "VolatileNotOptimizedAway"  
"optimized" } } */
! { dg-final { scan-tree-dump-not "NonVolatileNotOptimizedAway"  
"optimized" } } */
! { dg-final { cleanup-tree-dump "optimized" } } */

$ cat volatile8.f90
! { dg-do compile }
! { dg-options "-O2 -fdump-tree-optimized" }
! Tests whether volatile really works
! PR fortran/29601
logical, pointer, volatile :: t1
logical, pointer :: t2
integer :: i

t1 => NULL(t1)
t2 => NULL(t2)
do i = 1, 2
   if(associated(t1)) print *, 'VolatileNotOptimizedAway'
   if(associated(t2)) print *, 'NonVolatileNotOptimizedAway'
end do
end
! { dg-final { scan-tree-dump "VolatileNotOptimizedAway"  
"optimized" } } */
! { dg-final { scan-tree-dump-not "NonVolatileNotOptimizedAway"  
"optimized" } } */
! { dg-final { cleanup-tree-dump "optimized" } } */




More information about the Gcc-patches mailing list