-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fortran: Cray pointer comparison wrongly optimized away [PR106692]
PR fortran/106692 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_expr_op): Inhibit excessive optimization of Cray pointers by treating them as volatile in comparisons. gcc/testsuite/ChangeLog: * gfortran.dg/cray_pointers_13.f90: New test.
- Loading branch information
1 parent
75da7a6
commit c7754a2
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
! { dg-do run } | ||
! { dg-additional-options "-fcray-pointer" } | ||
! | ||
! PR fortran/106692 - Cray pointer comparison wrongly optimized away | ||
! | ||
! Contributed by Marek Polacek | ||
|
||
program test | ||
call test_cray() | ||
call test_cray2() | ||
end | ||
|
||
subroutine test_cray() | ||
pointer(ptrzz1 , zz1) | ||
ptrzz1=0 | ||
if (ptrzz1 .ne. 0) then | ||
print *, "test_cray: ptrzz1=", ptrzz1 | ||
stop 1 | ||
else | ||
call shape_cray(zz1) | ||
end if | ||
end | ||
|
||
subroutine shape_cray(zz1) | ||
pointer(ptrzz , zz) | ||
ptrzz=loc(zz1) | ||
if (ptrzz .ne. 0) then | ||
print *, "shape_cray: ptrzz=", ptrzz | ||
stop 3 | ||
end if | ||
end | ||
|
||
subroutine test_cray2() | ||
pointer(ptrzz1 , zz1) | ||
ptrzz1=0 | ||
if (0 == ptrzz1) then | ||
call shape_cray2(zz1) | ||
else | ||
print *, "test_cray2: ptrzz1=", ptrzz1 | ||
stop 2 | ||
end if | ||
end | ||
|
||
subroutine shape_cray2(zz1) | ||
pointer(ptrzz , zz) | ||
ptrzz=loc(zz1) | ||
if (.not. (0 == ptrzz)) then | ||
print *, "shape_cray2: ptrzz=", ptrzz | ||
stop 4 | ||
end if | ||
end |