From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106725 invoked by alias); 17 Nov 2015 20:34:46 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 106699 invoked by uid 89); 17 Nov 2015 20:34:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL,BAYES_40,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (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, 17 Nov 2015 20:34:45 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id tAHKYgZJ092336 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 17 Nov 2015 12:34:42 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id tAHKYgSW092335; Tue, 17 Nov 2015 12:34:42 -0800 (PST) (envelope-from sgk) Date: Tue, 17 Nov 2015 20:34:00 -0000 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/59910 -- structure constructor in DATA statement Message-ID: <20151117203442.GA92302@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J/dobhs11T7y2rNN" Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00104.txt.bz2 --J/dobhs11T7y2rNN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 777 Here's what looks like a fairly simple patch, but it leads to a question. Why does gfortran not try to reduce the components in a structure constructor in general? I've hidden the gfc_reduce_init_expr() behind a check for a DATA statement, but I suspect gfc_reduce_init_expr() may be useful for PARAMETER statements as well (need to check this!). Anyway, the patch has been built and tested on x86_64-*-freebsd. A slightly different patch was built and tested on i386-*-freebsd. OK to commit? 2015-11-17 Steven G. Kargl PR fortran/59910 * primary.c (gfc_match_structure_constructor): Reduce a structure constructor in a DATA statement. 2015-11-17 Steven G. Kargl PR fortran/59910 * gfortran.dg/pr59910.f90: -- Steve --J/dobhs11T7y2rNN Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pr59910.diff" Content-length: 1018 Index: gcc/fortran/primary.c =================================================================== --- gcc/fortran/primary.c (revision 230497) +++ gcc/fortran/primary.c (working copy) @@ -2722,6 +2722,12 @@ gfc_match_structure_constructor (gfc_sym return MATCH_ERROR; } + /* If a structure constructor is in a DATA statement, then each entity + in the structure constructor must be a constant. Try to reduce the + expression here. */ + if (gfc_in_match_data ()) + gfc_reduce_init_expr (e); + *result = e; return MATCH_YES; } Index: gcc/testsuite/gfortran.dg/pr59910.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr59910.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr59910.f90 (working copy) @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR fortran/59910 +! +program main + implicit none + type bar + integer :: limit(1) + end type + type (bar) :: testsuite + data testsuite / bar(reshape(source=[10],shape=[1])) / +end --J/dobhs11T7y2rNN--