re PR libfortran/27524 (-fbounds-check interacts with array function)
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>
Fri, 26 May 2006 21:18:45 +0000 (23:18 +0200)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Fri, 26 May 2006 21:18:45 +0000 (21:18 +0000)
PR fortran/27524

* trans-array.c (gfc_trans_dummy_array_bias): Don't use stride as
a temporary variable when -fbounds-check is enabled, since its
value will be needed later.

* gfortran.dg/bounds_check_1.f90: New test.

From-SVN: r114142

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

index eed3e0edf29668f24de9e42a4b1986b6b7257748..e4e2db2572122538cd84045b7a9c0c8363a9135c 100644 (file)
@@ -1,3 +1,10 @@
+2006-05-26  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR fortran/27524
+       * trans-array.c (gfc_trans_dummy_array_bias): Don't use stride as
+       a temporary variable when -fbounds-check is enabled, since its
+       value will be needed later.
+
 2006-05-26  Thomas Koenig  <Thomas.Koenig@online.de>
 
        PR fortran/23151
index 32283a3df06d074b5de9be680ea66f13dc6dae19..34742c3f7024c7462668188943c88c5f050b910f 100644 (file)
@@ -3564,7 +3564,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
   tree dumdesc;
   tree tmp;
   tree stmt;
-  tree stride;
+  tree stride, stride2;
   tree stmt_packed;
   tree stmt_unpacked;
   tree partial;
@@ -3711,9 +3711,9 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
 
              tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
                                 ubound, lbound);
-              stride = build2 (MINUS_EXPR, gfc_array_index_type,
+              stride2 = build2 (MINUS_EXPR, gfc_array_index_type,
                               dubound, dlbound);
-              tmp = fold_build2 (NE_EXPR, gfc_array_index_type, tmp, stride);
+              tmp = fold_build2 (NE_EXPR, gfc_array_index_type, tmp, stride2);
              gfc_trans_runtime_check (tmp, gfc_strconst_bounds, &block);
            }
        }
index e45fa3bc5b0df442e33b17938596e6a283a39635..4910f76c3e683c2e816e72373e5ec0602add86ba 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-26  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR fortran/27524
+       * gfortran.dg/bounds_check_1.f90: New test.
+
 2006-05-26  Ulrich Weigand  <uweigand@de.ibm.com>
 
        PR rtl-optimization/27661
diff --git a/gcc/testsuite/gfortran.dg/bounds_check_1.f90 b/gcc/testsuite/gfortran.dg/bounds_check_1.f90
new file mode 100644 (file)
index 0000000..c05f445
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do run }
+! { dg-options "-fbounds-check" }
+! PR fortran/27524
+    integer :: res(1)
+    res = F()
+    if (res(1) /= 1) call abort
+    contains
+      function F()
+        integer :: F(1)
+        f = 1
+      end function F
+    end