re PR fortran/35685 (UBOUND incorrect for run-time zero-sized section)
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 14 May 2008 21:17:54 +0000 (21:17 +0000)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 14 May 2008 21:17:54 +0000 (21:17 +0000)
        PR fortran/35685

        * trans-intrinsic.c (gfc_conv_intrinsic_bound): Correctly
        handle zero-size sections.

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

From-SVN: r135305

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

index 7ed34a61c0845ef52e7e7172fa65313642c62bd9..d478a2511df7581c8ebbb424c9e5dc9b94d876bf 100644 (file)
@@ -1,3 +1,9 @@
+2008-05-14  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/35685
+       * trans-intrinsic.c (gfc_conv_intrinsic_bound): Correctly
+       handle zero-size sections.
+
 2008-05-14  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/36215
index 9f022e7a09d2e847acd0dd59529296b9a1a938ab..2f9cadd199a08625d6d2dcb4d5134be21174a829 100644 (file)
@@ -938,6 +938,8 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, int upper)
          size = fold_build2 (MINUS_EXPR, gfc_array_index_type, ubound, lbound);
          se->expr = fold_build2 (PLUS_EXPR, gfc_array_index_type, size,
                                  gfc_index_one_node);
+         se->expr = fold_build2 (MAX_EXPR, gfc_array_index_type, se->expr,
+                                 gfc_index_zero_node);
        }
       else
        se->expr = gfc_index_one_node;
index ab790da0667499d056d99bc8d12ebce3e387fb99..f2795bb9c1fb24de36387cca9aa71f905e1c9a9b 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-14  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/35685
+       * gfortran.dg/bound_3.f90: New test.
+
 2008-05-14  Michael Meissner  <michael.meissner@amd.com>
            Dwarakanath Rajagopal  <dwarak.rajagopal@amd.com>
 
diff --git a/gcc/testsuite/gfortran.dg/bound_3.f90 b/gcc/testsuite/gfortran.dg/bound_3.f90
new file mode 100644 (file)
index 0000000..7b1696d
--- /dev/null
@@ -0,0 +1,20 @@
+! { dg-do run }
+!
+  call s(1,0)
+  call s(2,0)
+  call s(3,0)
+  call s(4,0)
+  call s(5,1)
+  call s(6,2)
+  call s(7,3)
+contains
+  subroutine s(n,m)
+    implicit none
+    integer n, m
+    real x(10)
+    if (any (lbound(x(5:n)) /= 1)) call abort
+    if (lbound(x(5:n),1) /= 1) call abort
+    if (any (ubound(x(5:n)) /= m)) call abort
+    if (ubound(x(5:n),1) /= m) call abort
+  end subroutine
+end program