re PR fortran/19777 (-fbounds-check catches non-existent bounds violation)
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>
Sat, 27 May 2006 09:41:42 +0000 (11:41 +0200)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Sat, 27 May 2006 09:41:42 +0000 (09:41 +0000)
PR fortran/19777

* trans-array.c (gfc_conv_array_ref): Don't perform out-of-bounds
checking for assumed-size arrrays.

* gfortran.dg/bounds_check_2.f: New test.

From-SVN: r114153

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/bounds_check_2.f [new file with mode: 0644]

index 187831137f00e89f213db7b3b710930367732e85..c5a0c0a6afabc1d9259140e1b9b5951aa864c1b0 100644 (file)
@@ -1,3 +1,9 @@
+2006-05-27  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR fortran/19777
+       * trans-array.c (gfc_conv_array_ref): Don't perform out-of-bounds
+       checking for assumed-size arrrays.
+
 2006-05-27  Paul Thomas  <pault@gcc.gnu.org>
 
        * trans-intrinsic.c (gfc_conv_associated): If pointer in first
index 34742c3f7024c7462668188943c88c5f050b910f..737beeffc35bbd2aeac0ddf2d60fe014778ba2cd 100644 (file)
@@ -1948,7 +1948,7 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar)
       gfc_conv_expr_type (&indexse, ar->start[n], gfc_array_index_type);
       gfc_add_block_to_block (&se->pre, &indexse.pre);
 
-      if (flag_bounds_check)
+      if (flag_bounds_check && ar->as->type != AS_ASSUMED_SIZE)
        {
          /* Check array bounds.  */
          tree cond;
index 07b8fbe30c2d5b1874834d240b3044a374febfc1..78c926ec17f873bbc5fd6990131992a47929ec5b 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-27  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR fortran/19777
+       * gfortran.dg/bounds_check_2.f: New test.
+
 2006-05-27  Janne Blomqvist  <jb@gcc.gnu.org>
 
        * gfortran.dg/hollerith_f95.f90: Add -fall-intrinsics.
diff --git a/gcc/testsuite/gfortran.dg/bounds_check_2.f b/gcc/testsuite/gfortran.dg/bounds_check_2.f
new file mode 100644 (file)
index 0000000..0160723
--- /dev/null
@@ -0,0 +1,23 @@
+! { dg-do run }
+! { dg-options "-fbounds-check" }
+! PR fortran/19777
+      implicit none
+      integer          npts
+      parameter        (npts=10)
+      double precision v(npts)
+      external         init1
+
+      call init1 (npts, v)
+      end
+
+      subroutine init1 (npts, v)
+      implicit none
+      integer          npts
+      double precision v(*)
+
+      integer          i
+
+      do 10 i = 1, npts
+         v(i) = 0
+ 10   continue
+      end