From patchwork Tue Nov 5 17:07:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 288586 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A96F22C007E for ; Wed, 6 Nov 2013 04:08:13 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=njp7ACC219fvNya4IIeONL+cv7apj0g+Tevo8PnGDWGm+l4p5HClB D+iijVCuemrxu1R9z4xMp912vSAr/3tBLWtuOxiCaFGxH/+szXPU+/GlbhWGSLb6 9EtzI69Y/pFqoOYyxIgVbKKkiXhA8OFTO2j9CGb6YbdfnTr27vIiUs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=kK5L0wQx9ib93poLWU6DRsQ28UQ=; b=f1/WmlvukLdFhUYijJMC G6zU9x9dzBshChlr9e1JpAKrRqe3jMBZPiC6Kvd5SU5vyDvs9CadPI4AYNKICoQj 5RwGfx3WsxTZKs/yGdqHeQD8Wx35ESQ0PjqBNMxcJsFgaGeJhRAt+C6afEpuopNe O+r7UNrufk2XyIxFFBI9S/s= Received: (qmail 6364 invoked by alias); 5 Nov 2013 17:08:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 6345 invoked by uid 89); 5 Nov 2013 17:08:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RDNS_NONE, URIBL_BLOCKED autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: troutmask.apl.washington.edu Received: from Unknown (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 05 Nov 2013 17:08:01 +0000 Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.7/8.14.7) with ESMTP id rA5H7r0v028919; Tue, 5 Nov 2013 09:07:53 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.7/8.14.7/Submit) id rA5H7r7A028918; Tue, 5 Nov 2013 09:07:53 -0800 (PST) (envelope-from sgk) Date: Tue, 5 Nov 2013 09:07:53 -0800 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/58989 Message-ID: <20131105170753.GA25908@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) The inlined patch fixes a problem where an array constructor is used as the shape argument in RESHAPE. The patch is straightforward and self-explanatory. Regression tested on x86_64-*-freebsd11 Ok? 2013-11-05 Steven G. Kargl PR fortran/58989 * check.c (gfc_check_reshape): ensure that shape is a constant expression. 2013-11-05 Steven G. Kargl PR fortran/58989 * gfortran.dg/reshape_6.f90: New test. Index: gcc/fortran/check.c =================================================================== --- gcc/fortran/check.c (revision 204372) +++ gcc/fortran/check.c (working copy) @@ -3277,7 +3277,7 @@ gfc_check_reshape (gfc_expr *source, gfc "than %d elements", &shape->where, GFC_MAX_DIMENSIONS); return false; } - else if (shape->expr_type == EXPR_ARRAY) + else if (shape->expr_type == EXPR_ARRAY && gfc_is_constant_expr (shape)) { gfc_expr *e; int i, extent; Index: gcc/testsuite/gfortran.dg/reshape_6.f90 =================================================================== --- gcc/testsuite/gfortran.dg/reshape_6.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/reshape_6.f90 (working copy) @@ -0,0 +1,19 @@ +! { dg-do compile } +! PR fortran/58989 +! +program test + + real(8), dimension(4,4) :: fluxes + real(8), dimension(2,2,2,2) :: f + integer, dimension(3) :: dmmy + integer, parameter :: indx(4)=(/2,2,2,2/) + + fluxes = 1 + + dmmy = (/2,2,2/) + + f = reshape(fluxes,(/dmmy,2/)) ! Caused an ICE + f = reshape(fluxes,(/2,2,2,2/)) ! Works as expected + f = reshape(fluxes,indx) ! Works as expected + +end program test