re PR fortran/36670 (Missing compile-time checks on sum and product)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 7 Jul 2008 19:45:55 +0000 (19:45 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 7 Jul 2008 19:45:55 +0000 (19:45 +0000)
2008-07-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/36670
* iresolve.c (gfc_resolve_product):  Set shape of return
value from array.
(gfc_resolve_sum):  Likewise.

2008-07-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/36670
* gfortran.dg/product_sum_bounds_1.f90:  New test case.

From-SVN: r137595

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

index 0369a0f34836e5f274dfb6a695f95d7bc0d6e2fb..44f61fa245871ccebc02901c0787183ba43c883d 100644 (file)
@@ -1,3 +1,10 @@
+2008-07-07  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/36670
+       * iresolve.c (gfc_resolve_product):  Set shape of return
+       value from array.
+       (gfc_resolve_sum):  Likewise.
+
 2008-07-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/36726
index 64a24e80007445ad178b86d86dbbf64cbcaffba1..2c804143ba9aa5ee2c794ce2af923fc5664176d7 100644 (file)
@@ -1788,6 +1788,7 @@ gfc_resolve_product (gfc_expr *f, gfc_expr *array, gfc_expr *dim,
   if (dim != NULL)
     {
       f->rank = array->rank - 1;
+      f->shape = gfc_copy_shape_excluding (array->shape, array->rank, dim);
       gfc_resolve_dim_arg (dim);
     }
 
@@ -2271,6 +2272,7 @@ gfc_resolve_sum (gfc_expr *f, gfc_expr *array, gfc_expr *dim, gfc_expr *mask)
   if (dim != NULL)
     {
       f->rank = array->rank - 1;
+      f->shape = gfc_copy_shape_excluding (array->shape, array->rank, dim);
       gfc_resolve_dim_arg (dim);
     }
 
index 143f75db13d4319592f62633ad1fc46ae0e3c869..97f1e9bf60c8d2fd9e9530dc2124f6900bf2c269 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-07  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/36670
+       * gfortran.dg/product_sum_bounds_1.f90:  New test case.
+
 2008-07-07  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/36341
diff --git a/gcc/testsuite/gfortran.dg/product_sum_bounds_1.f90 b/gcc/testsuite/gfortran.dg/product_sum_bounds_1.f90
new file mode 100644 (file)
index 0000000..c639089
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+program main
+  real, dimension(4,3) :: a
+  real, dimension(2) :: b
+  a = 21.
+  b = product(a,dim=1) ! { dg-error "Different shape" }
+  b = sum(a,dim=2) ! { dg-error "Different shape" }
+end program main