From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23070 invoked by alias); 1 Jul 2008 19:18:59 -0000 Received: (qmail 23055 invoked by uid 22791); 1 Jul 2008 19:18:58 -0000 X-Spam-Check-By: sourceware.org Received: from smtp3.netcologne.de (HELO smtp3.netcologne.de) (194.8.194.66) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 01 Jul 2008 19:18:26 +0000 Received: from [192.168.0.195] (xdsl-213-168-116-10.netcologne.de [213.168.116.10]) by smtp3.netcologne.de (Postfix) with ESMTP id 8B2DA67492; Tue, 1 Jul 2008 21:18:23 +0200 (CEST) Subject: [patch, fortran] Fix PR 36670, bounds check on product and sum From: Thomas Koenig To: fortran@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org Content-Type: multipart/mixed; boundary="=-SSyq0aHvMrOor3ldtPI/" Date: Tue, 01 Jul 2008 19:32:00 -0000 Message-Id: <1214939902.2757.2.camel@meiner.onlinehome.de> Mime-Version: 1.0 X-Mailer: Evolution 2.22.2 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-07/txt/msg00041.txt.bz2 --=-SSyq0aHvMrOor3ldtPI/ Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 484 Hello world, this rather self-explanatory patch fixes the missing bounds check on the product and sum intrinsics. Regression-tested on i686-pc-linux-gnu. OK for trunk? Thomas 2008-07-01 Thomas Koenig PR fortran/36670 * iresolve.c (gfc_resolve_product): Set shape of return value from array. (gfc_resolve_sum): Likewise. 2008-07-01 Thomas Koenig PR fortran/36670 * gfortran.dg/product_sum_bounds_1.f90: New test case. --=-SSyq0aHvMrOor3ldtPI/ Content-Disposition: attachment; filename=product_sum_bounds_1.f90 Content-Type: text/x-fortran; name=product_sum_bounds_1.f90; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 222 ! { 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 --=-SSyq0aHvMrOor3ldtPI/ Content-Disposition: attachment; filename=sum_product.diff Content-Type: text/x-patch; name=sum_product.diff; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 736 Index: /home/ig25/gcc/trunk/gcc/fortran/iresolve.c =================================================================== --- /home/ig25/gcc/trunk/gcc/fortran/iresolve.c (revision 137255) +++ /home/ig25/gcc/trunk/gcc/fortran/iresolve.c (working copy) @@ -1788,6 +1788,7 @@ gfc_resolve_product (gfc_expr *f, gfc_ex 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 * if (dim != NULL) { f->rank = array->rank - 1; + f->shape = gfc_copy_shape_excluding (array->shape, array->rank, dim); gfc_resolve_dim_arg (dim); } --=-SSyq0aHvMrOor3ldtPI/--