re PR fortran/31011 ([4.2 and 4.1 only] Incorrect error: parameter array sections)
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 8 Mar 2007 09:09:38 +0000 (09:09 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 8 Mar 2007 09:09:38 +0000 (09:09 +0000)
2007-03-08 Paul Thomas <pault@gcc.gnu.org>

PR fortran/31011
* expr.c (find_array_section): Correct arithmetic for section
size.

2007-03-08 Paul Thomas <pault@gcc.gnu.org>

PR fortran/31011
* gfortran.dg/parameter_array_section_2.f90: New test.

From-SVN: r122689

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/parameter_array_section_2.f90 [new file with mode: 0644]

index cbdf82d..987bc50 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-08  Paul Thomas  <pault@gcc.gnu.org>\r
+\r
+       PR fortran/31011\r
+       * expr.c (find_array_section): Correct arithmetic for section\r
+       size.\r
+\r
 2007-03-07  Brooks Moses  <brooks.moses@codesourcery.com>
 
        * iresolve.c (gfc_resolve_ishftc): Correct s_kind value.
index dbe5188..06f4d20 100644 (file)
@@ -1137,8 +1137,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
            }
 
          /* Calculate the number of elements and the shape.  */
-         mpz_abs (tmp_mpz, stride[d]);
-         mpz_div (tmp_mpz, stride[d], tmp_mpz);
+         mpz_set (tmp_mpz, stride[d]);
          mpz_add (tmp_mpz, end[d], tmp_mpz);
          mpz_sub (tmp_mpz, tmp_mpz, ctr[d]);
          mpz_div (tmp_mpz, tmp_mpz, stride[d]);
index 81dd95d..6267c8a 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-08  Paul Thomas  <pault@gcc.gnu.org>\r
+\r
+       PR fortran/31011\r
+       * gfortran.dg/parameter_array_section_2.f90: New test.\r
+
 2007-03-08  Volker Reichelt  <reichelt@netcologne.de>
 
        PR c++/30852
diff --git a/gcc/testsuite/gfortran.dg/parameter_array_section_2.f90 b/gcc/testsuite/gfortran.dg/parameter_array_section_2.f90
new file mode 100644 (file)
index 0000000..aa212c0
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do run }
+! { dg-options "-O" }
+! Test the fix for PR31011 in which the length of the array sections
+! with stride other than unity were incorrectly calculated.
+!
+! Contributed by <terry@chem.gu.se>
+!
+program PotentialMatrix
+ implicit none
+ real(kind=8),dimension(2),parameter::v2=(/1,2/)
+ real(kind=8),dimension(4),parameter::v4=(/1,2,3,4/)
+ if (any (v2*v4(1:3:2) .ne. (/1,6/))) call abort ()
+ if (any (v2*v4(3:1:-2) .ne. (/3,2/))) call abort ()
+end