From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76943 invoked by alias); 4 Apr 2016 02:39:43 -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 76848 invoked by uid 89); 4 Apr 2016 02:39:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:InterMail X-Spam-User: qpsmtpd, 2 recipients X-HELO: mtaout004-public.msg.strl.va.charter.net Received: from mtaout004-public.msg.strl.va.charter.net (HELO mtaout004-public.msg.strl.va.charter.net) (68.114.190.29) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Apr 2016 02:39:27 +0000 Received: from impout005 ([68.114.189.20]) by mtaout004.msg.strl.va.charter.net (InterMail vM.9.00.021.00 201-2473-182) with ESMTP id <20160404023926.EJSH7236.mtaout004.msg.strl.va.charter.net@impout005>; Sun, 3 Apr 2016 21:39:26 -0500 Received: from quattro.localdomain ([96.41.215.23]) by impout005 with charter.net id e2fQ1s0060Wrkg0012fQ9W; Sun, 03 Apr 2016 21:39:26 -0500 X-Authority-Analysis: v=2.1 cv=L9mTQoj8 c=1 sm=1 tr=0 a=salB9WdMPIDduBH7JsZfrA==:117 a=salB9WdMPIDduBH7JsZfrA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=r77TgQKjGQsHNAKrUKIA:9 a=7DQ6vndm1Ny39CwyXlsA:9 a=QEXdDO2ut3YA:10 a=uEWXd8nK9z6rmEQnzMwA:9 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 Subject: Re: [patch, fortran] PR68566 ICE on using unusable array in reshape To: =?UTF-8?Q?Dominique_d'Humi=c3=a8res?= References: <56FFD9C9.1060208@charter.net> Cc: fortran@gcc.gnu.org, gcc-patches From: Jerry DeLisle Message-ID: <5701D3DB.9080807@charter.net> Date: Mon, 04 Apr 2016 02:39:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56FFD9C9.1060208@charter.net> Content-Type: multipart/mixed; boundary="------------040303090502070507070006" X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00019.txt.bz2 This is a multi-part message in MIME format. --------------040303090502070507070006 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-length: 1003 On 04/02/2016 07:40 AM, Jerry DeLisle wrote: > On 04/02/2016 05:42 AM, Dominique d'Humières wrote: >> >>> Le 2 avr. 2016 à 11:44, Dominique d'Humières a écrit : >>> >>> Hi Jerry, >>> >>>> ... >>>> I will add an additional test case for the original posted problem in the PR. >>>> Two existing tests get exercised, changing the error message. Finding the >>>> problems earlier in the matchers I think is the right way to go. I am curious if >>>> the old checks ever get triggered (I will look into that a little later. >>> >>> (2) Before your patch the errors were >>> >>> Error: Expression at (1) must be of INTEGER type, found REAL >>> >>> How difficult is it to restore the "found … « ? > > I like that idea and not too difficult to do. ;) > Here is an updated patch with Dominique's suggestion to tell what type was found in the error message. Patch includes a new test case fore the original test case in the PR and updates of existing tests. OK for trunk? Jerry --------------040303090502070507070006 Content-Type: text/x-patch; name="pr68566a.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr68566a.diff" Content-length: 4247 diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 2fc9dfaf..1430e802 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -421,10 +421,15 @@ match_array_element_spec (gfc_array_spec *as) if (!gfc_expr_check_typed (*upper, gfc_current_ns, false)) return AS_UNKNOWN; - if ((*upper)->expr_type == EXPR_FUNCTION && (*upper)->ts.type == BT_UNKNOWN - && (*upper)->symtree && strcmp ((*upper)->symtree->name, "null") == 0) - { - gfc_error ("Expecting a scalar INTEGER expression at %C"); + if (((*upper)->expr_type == EXPR_CONSTANT + && (*upper)->ts.type != BT_INTEGER) || + ((*upper)->expr_type == EXPR_FUNCTION + && (*upper)->ts.type == BT_UNKNOWN + && (*upper)->symtree + && strcmp ((*upper)->symtree->name, "null") == 0)) + { + gfc_error ("Expecting a scalar INTEGER expression at %C, found %s", + gfc_basic_typename ((*upper)->ts.type)); return AS_UNKNOWN; } @@ -448,10 +453,15 @@ match_array_element_spec (gfc_array_spec *as) if (!gfc_expr_check_typed (*upper, gfc_current_ns, false)) return AS_UNKNOWN; - if ((*upper)->expr_type == EXPR_FUNCTION && (*upper)->ts.type == BT_UNKNOWN - && (*upper)->symtree && strcmp ((*upper)->symtree->name, "null") == 0) + if (((*upper)->expr_type == EXPR_CONSTANT + && (*upper)->ts.type != BT_INTEGER) || + ((*upper)->expr_type == EXPR_FUNCTION + && (*upper)->ts.type == BT_UNKNOWN + && (*upper)->symtree + && strcmp ((*upper)->symtree->name, "null") == 0)) { - gfc_error ("Expecting a scalar INTEGER expression at %C"); + gfc_error ("Expecting a scalar INTEGER expression at %C, found %s", + gfc_basic_typename ((*upper)->ts.type)); return AS_UNKNOWN; } diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 12a8f32e..a6310107 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -5163,6 +5163,9 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp, || !is_constant_array_expr (order_exp)) return NULL; + if (source->shape == NULL) + return NULL; + /* Proceed with simplification, unpacking the array. */ mpz_init (index); diff --git a/gcc/testsuite/gfortran.dg/pr36192.f90 b/gcc/testsuite/gfortran.dg/pr36192.f90 index df3bfd75..ebf95e35 100644 --- a/gcc/testsuite/gfortran.dg/pr36192.f90 +++ b/gcc/testsuite/gfortran.dg/pr36192.f90 @@ -3,7 +3,6 @@ ! program three_body real, parameter :: n = 2, d = 2 - real, dimension(n,d) :: x ! { dg-error "of INTEGER type|of INTEGER type" } - x(1,:) = (/ 1.0, 0.0 /) + real, dimension(n,d) :: x ! { dg-error "Expecting a scalar INTEGER" } + x(1,:) = (/ 1.0, 0.0 /) ! { dg-error "Unclassifiable" } end program three_body -! { dg-prune-output "have constant shape" } diff --git a/gcc/testsuite/gfortran.dg/pr36192_1.f90 b/gcc/testsuite/gfortran.dg/pr36192_1.f90 index 77df3176..687a465f 100644 --- a/gcc/testsuite/gfortran.dg/pr36192_1.f90 +++ b/gcc/testsuite/gfortran.dg/pr36192_1.f90 @@ -2,11 +2,11 @@ ! PR fortran/36192 program three_body real, parameter :: n = 2, d = 2 - real, dimension(n,d) :: x_hq ! { dg-error "of INTEGER type|of INTEGER type" } + real, dimension(n,d) :: x_hq ! { dg-error "Expecting a scalar INTEGER" } call step(x_hq) contains subroutine step(x) real, dimension(:,:), intent(in) :: x end subroutine step end program three_body -! { dg-prune-output "must have constant shape" } +! { dg-prune-output "Rank mismatch in argument" } diff --git a/gcc/testsuite/gfortran.dg/real_dimension_1.f b/gcc/testsuite/gfortran.dg/real_dimension_1.f index 73e9131a..3dd1a5af 100644 --- a/gcc/testsuite/gfortran.dg/real_dimension_1.f +++ b/gcc/testsuite/gfortran.dg/real_dimension_1.f @@ -1,7 +1,7 @@ ! { dg-do compile } -! PR 34305 - make sure there's an error message for specifying a +! PR 34305 - Test for specifying a real as dimension program test - parameter (datasize = 1000) - dimension idata (datasize) ! { dg-error "must be of INTEGER type|must have constant shape" } - idata (1) = -1 + real , parameter :: dsize = 1000 + dimension idata (dsize) ! { dg-error "scalar INTEGER expression" } + idata (1) = -1 ! { dg-error "must have the pointer attribute" } end --------------040303090502070507070006--