diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2009-08-25 17:05:10 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2009-08-25 17:05:10 +0000 |
commit | 8c39b987960b0db71ea60407cc948702c9689092 (patch) | |
tree | f829815ebbd78c2cba3d70da5c55d9d5439b5f9b /gcc | |
parent | f76d6e6f37b2411477583ecf6f878241883ef7d0 (diff) | |
download | gcc-8c39b987960b0db71ea60407cc948702c9689092.zip gcc-8c39b987960b0db71ea60407cc948702c9689092.tar.gz gcc-8c39b987960b0db71ea60407cc948702c9689092.tar.bz2 |
re PR libfortran/34670 (bounds checking for array intrinsics)
2009-08-25 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/34670
* runtime/bounds.c (count_0): New function.
* intrinsics/unpack_generic (unpack_bounds): New function.
(unpack_internal): Remove zero stride checks.
(unpack1): Use unpack_bounds.
(unpack1_char): Likeweise.
(unpack1_char4): Likewise
(unpack0): Likewise.
(unpack0_char): Likewise.
(unpack0_char4): Likewise.
2009-08-25 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/34670
* gfortran.dg/unpack_bounds_1.f90: New test.
* gfortran.dg/unpack_bounds_2.f90: New test.
* gfortran.dg/unpack_bounds_3.f90: New test.
From-SVN: r151085
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rwxr-xr-x | gcc/testsuite/gfortran.dg/unpack_bounds_1.f90 | 18 | ||||
-rwxr-xr-x | gcc/testsuite/gfortran.dg/unpack_bounds_2.f90 | 18 | ||||
-rwxr-xr-x | gcc/testsuite/gfortran.dg/unpack_bounds_3.f90 | 21 |
4 files changed, 64 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7cfcccd..702fb68 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2009-08-25 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR libfortran/34670 + * gfortran.dg/unpack_bounds_1.f90: New test. + * gfortran.dg/unpack_bounds_2.f90: New test. + * gfortran.dg/unpack_bounds_3.f90: New test. + 2009-08-25 Eric Botcazou <ebotcazou@adacore.com> * gnat.dg/slice7.adb: New test. diff --git a/gcc/testsuite/gfortran.dg/unpack_bounds_1.f90 b/gcc/testsuite/gfortran.dg/unpack_bounds_1.f90 new file mode 100755 index 0000000..360790b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unpack_bounds_1.f90 @@ -0,0 +1,18 @@ +! { dg-do run } +! { dg-options "-fbounds-check" } +! { dg-shouldfail "Incorrect extent in return value of UNPACK intrinsic in dimension 2: is 1, should be 2" } +program main + integer, allocatable, dimension(:) :: vector + integer, allocatable, dimension(:,:) :: res + logical, allocatable, dimension(:,:) :: mask + + allocate (vector(2)) + allocate (mask(2,2)) + allocate (res(2,1)) + + vector = 1 + mask = reshape((/ .TRUE., .FALSE., .FALSE., .TRUE. /),(/2,2/)) + res = unpack(vector, mask, 0) + print *,res +end program main +! { dg-output "Fortran runtime error: Incorrect extent in return value of UNPACK intrinsic in dimension 2: is 1, should be 2" } diff --git a/gcc/testsuite/gfortran.dg/unpack_bounds_2.f90 b/gcc/testsuite/gfortran.dg/unpack_bounds_2.f90 new file mode 100755 index 0000000..fd049f5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unpack_bounds_2.f90 @@ -0,0 +1,18 @@ +! { dg-do run } +! { dg-options "-fbounds-check" } +! { dg-shouldfail "Incorrect size of return value in UNPACK intrinsic: should be at least 3, is 2" } +program main + integer, allocatable, dimension(:) :: vector + integer, allocatable, dimension(:,:) :: res + logical, allocatable, dimension(:,:) :: mask + + allocate (vector(2)) + allocate (mask(2,2)) + allocate (res(2,2)) + + vector = 1 + mask = reshape((/ .TRUE., .TRUE., .FALSE., .TRUE. /),(/2,2/)) + res = unpack(vector, mask, 0) + print *,res +end program main +! { dg-output "Fortran runtime error: Incorrect size of return value in UNPACK intrinsic: should be at least 3, is 2" } diff --git a/gcc/testsuite/gfortran.dg/unpack_bounds_3.f90 b/gcc/testsuite/gfortran.dg/unpack_bounds_3.f90 new file mode 100755 index 0000000..c6734b1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unpack_bounds_3.f90 @@ -0,0 +1,21 @@ +! { dg-do run } +! { dg-options "-fbounds-check" } +! { dg-shouldfail "Incorrect size of return value in UNPACK intrinsic: should be at least 3, is 2" } +program main + integer, allocatable, dimension(:) :: vector + integer, allocatable, dimension(:,:) :: res + integer, allocatable, dimension(:,:) :: field + logical, allocatable, dimension(:,:) :: mask + + allocate (vector(3)) + allocate (mask(2,2)) + allocate (res(2,2)) + allocate (field(3,2)) + + vector = 1 + field = 0 + mask = reshape((/ .TRUE., .TRUE., .FALSE., .TRUE. /),(/2,2/)) + res = unpack(vector, mask, field) + print *,res +end program main +! { dg-output "Fortran runtime error: Incorrect extent in FIELD of UNPACK intrinsic in dimension 1: is 3, should be 2" } |