From patchwork Mon Feb 12 10:46:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 871977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-473063-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="m/dC0NtL"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zg2R82lfFz9t2l for ; Mon, 12 Feb 2018 21:46:42 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=KGzTr2a8u5UCOy9CekQU1HwAG5DZfgIx+2+VfGaVs42omCzFRI FqWustBxFbZt5rH/zcyATOaxApub/K2cSpMEHoQSm+MRjDGMXby7kpQFIADMGY2X OrCbnwKzV0uy4GGGqx+IO7e/HyfwznsIsZxQr+K9r12pewdg8amp2ENxQ= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=U3z/H8+tZvv7VX4KcBdB64pF/cs=; b=m/dC0NtLNcin36JUmSKE MDLwaV5GNXl0hji/diXMmPlR7zvTjrw6ziOKtdZ14SE0KrAdcc3pCaR2EbHudhnU cu+LzJZ2yZ3I206qwj4Tm566QOWllFERjxL6z9mfNens+n2r6StOE6SOqsVv1X+T bpa4VRiOWp2ExboQ5wBj5XA= Received: (qmail 127718 invoked by alias); 12 Feb 2018 10:46:31 -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 103226 invoked by uid 89); 12 Feb 2018 10:46:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout3.netcologne.de Received: from cc-smtpout3.netcologne.de (HELO cc-smtpout3.netcologne.de) (89.1.8.213) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Feb 2018 10:46:17 +0000 Received: from cc-smtpin2.netcologne.de (cc-smtpin2.netcologne.de [89.1.8.202]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id E8DAD12826; Mon, 12 Feb 2018 11:46:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin2.netcologne.de (Postfix) with ESMTP id DA2FD11DB5; Mon, 12 Feb 2018 11:46:14 +0100 (CET) Received: from [78.35.153.101] (helo=cc-smtpin2.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.9) (envelope-from ) id 5a817076-02b8-7f0000012729-7f0000018a8a-1 for ; Mon, 12 Feb 2018 11:46:14 +0100 Received: from [192.168.178.20] (xdsl-78-35-153-101.netcologne.de [78.35.153.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin2.netcologne.de (Postfix) with ESMTPSA; Mon, 12 Feb 2018 11:46:13 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix handling of assumed-size arrays in inline matmul Message-ID: <4c520b3f-0645-edac-0eda-e19621407f78@netcologne.de> Date: Mon, 12 Feb 2018 11:46:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Hello world, the attached patch fixes a regression where a rejects-valid would be issued. OK for the affected branches, trunk and gcc-7? Regards Thomas 2018-02-12 Thomas Koenig PR fortran/84270 * frontend-passes (scalarized_expr): If the expression is an assumed size array, leave in the last reference and pass AR_SECTION instead of AR_FULL to gfc_resolve in order to avoid an error. 2018-02-12 Thomas Koenig PR fortran/84270 * gfortran.dg/inline_matmul_22.f90: New test. Index: frontend-passes.c =================================================================== --- frontend-passes.c (Revision 257347) +++ frontend-passes.c (Arbeitskopie) @@ -3567,11 +3567,27 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index, is the lbound of a full ref. */ int j; gfc_array_ref *ar; + int to; ar = &ref->u.ar; - ar->type = AR_FULL; - for (j = 0; j < ar->dimen; j++) + + /* For assumed size, we need to keep around the final + reference in order not to get an error on resolution + below, and we cannot use AR_FULL. */ + + if (ar->as->type == AS_ASSUMED_SIZE) { + ar->type = AR_SECTION; + to = ar->dimen - 1; + } + else + { + to = ar->dimen; + ar->type = AR_FULL; + } + + for (j = 0; j < to; j++) + { gfc_free_expr (ar->start[j]); ar->start[j] = NULL; gfc_free_expr (ar->end[j]);