diff options
author | Tobias Burnus <burnus@gcc.gnu.org> | 2009-03-28 22:39:26 +0100 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2009-03-28 22:39:26 +0100 |
commit | 33abc8454687da28c851b1089b7540a3669c3548 (patch) | |
tree | 035dde6bb8193a46fa1d35b8af11978d76676b9d /gcc/testsuite | |
parent | 63f90eb7b0a70009743f7bb0035de2c956add767 (diff) | |
download | gcc-33abc8454687da28c851b1089b7540a3669c3548.zip gcc-33abc8454687da28c851b1089b7540a3669c3548.tar.gz gcc-33abc8454687da28c851b1089b7540a3669c3548.tar.bz2 |
re PR fortran/34656 (modifies do loop variable)
2009-03-28 Tobias Burnus <burnus@net-b.de>
PR fortran/34656
* trans-stmt.c (gfc_trans_simple_do, gfc_trans_do):
Add GFC_RTCHECK_DO support.
* option.c (gfc_handle_runtime_check_option): Enable
* GFC_RTCHECK_DO.
* invoke.texi (-fcheck): Document "do" option.
From-SVN: r145210
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/do_check_1.f90 | 16 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/do_check_2.f90 | 20 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/do_check_3.f90 | 22 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/do_check_4.f90 | 21 |
5 files changed, 87 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7a870c2..ee2e360 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2009-03-28 Tobias Burnus <burnus@net-b.de> + + PR fortran/34656 + * gfortran.dg/do_check_1.f90: Add test. + * gfortran.dg/do_check_2.f90: Add test. + * gfortran.dg/do_check_3.f90: Add test. + * gfortran.dg/do_check_4.f90: Add test. + 2009-03-28 Jan Hubicka <jh@suse.cz> * gcc.dg/attr-noinline.c: Avoid pure-const optimization. diff --git a/gcc/testsuite/gfortran.dg/do_check_1.f90 b/gcc/testsuite/gfortran.dg/do_check_1.f90 new file mode 100644 index 0000000..94d8a84 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/do_check_1.f90 @@ -0,0 +1,16 @@ +! { dg-do run } +! { dg-options "-fcheck=do" } +! { dg-shouldfail "DO check" } +! +! PR fortran/34656 +! Run-time check for zero STEP +! +program test + implicit none + integer :: i,j + j = 0 + do i = 1, 40, j + print *, i + end do +end program test +! { dg-output "Fortran runtime error: DO step value is zero" } diff --git a/gcc/testsuite/gfortran.dg/do_check_2.f90 b/gcc/testsuite/gfortran.dg/do_check_2.f90 new file mode 100644 index 0000000..c40760d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/do_check_2.f90 @@ -0,0 +1,20 @@ +! { dg-do run } +! { dg-options "-fcheck=do" } +! { dg-shouldfail "DO check" } +! +! PR fortran/34656 +! Run-time check for modifing loop variables +! +program test + implicit none + integer :: i,j + do i = 1, 10 + call modLoopVar(i) + end do +contains + subroutine modLoopVar(i) + integer :: i + i = i + 1 + end subroutine modLoopVar +end program test +! { dg-output "Fortran runtime error: Loop variable has been modified" } diff --git a/gcc/testsuite/gfortran.dg/do_check_3.f90 b/gcc/testsuite/gfortran.dg/do_check_3.f90 new file mode 100644 index 0000000..15086c2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/do_check_3.f90 @@ -0,0 +1,22 @@ +! { dg-do run } +! { dg-options "-fcheck=do" } +! { dg-shouldfail "DO check" } +! +! PR fortran/34656 +! Run-time check for modifing loop variables +! +program test + implicit none + real :: i, j, k + j = 10.0 + k = 1.0 + do i = 1.0, j, k ! { dg-warning "must be integer" } + call modLoopVar(i) + end do +contains + subroutine modLoopVar(x) + real :: x + x = x + 1 + end subroutine modLoopVar +end program test +! { dg-output "Fortran runtime error: Loop variable has been modified" } diff --git a/gcc/testsuite/gfortran.dg/do_check_4.f90 b/gcc/testsuite/gfortran.dg/do_check_4.f90 new file mode 100644 index 0000000..65bc92c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/do_check_4.f90 @@ -0,0 +1,21 @@ +! { dg-do run } +! { dg-options "-fcheck=do" } +! { dg-shouldfail "DO check" } +! +! PR fortran/34656 +! Run-time check for modifing loop variables +! +PROGRAM test + IMPLICIT NONE + INTEGER :: i + DO i=1,100 + CALL do_something() + ENDDO +CONTAINS + SUBROUTINE do_something() + IMPLICIT NONE + DO i=1,10 + ENDDO + END SUBROUTINE do_something +END PROGRAM test +! { dg-output "Fortran runtime error: Loop variable has been modified" } |