From patchwork Thu Mar 29 18:07:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 892913 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-475622-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="EeTdeeT2"; 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 40Bt5G6XgHz9s1t for ; Fri, 30 Mar 2018 05:07:45 +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=EtWuBIxvpS7y4SVh2McORxWwETMhxfB3NZj/PS6YyLHcJUDhM5 lk6oXyRwW1rCrhJb1JRsiuXhOKjdeLQ9a22wOtOi0Y4z60Re2TLj/Og1JBDt9mEt wjEtdDR6wVKSD3nGD6BJ0K+K7INZR4WuCR+YXWOSPydcsHlewt1u6ZN5Y= 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=AYw+rNe+c+svd1THeyEXJkSSYOA=; b=EeTdeeT2nU2Zv8yR2wP1 3RRpQoCdVKXdkMf4HfRQ+rQhOlNxvDGvlLFV1jhYAiJgBtEDUIEXv3ecSbsKPUBA L/sTUnP5uIpLiiUrtKxFyZQaL3vGdUvtFfTWUYlgkvotQ2Z9jyK1NsgkQKxleF+G +Mjas1A9PES/KJOjBLqsJl8= Received: (qmail 99016 invoked by alias); 29 Mar 2018 18:07:34 -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 98885 invoked by uid 89); 29 Mar 2018 18:07:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:sk:!192.16, H*RU:sk:!192.16, saga, H*Ad:U*tkoenig 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; Thu, 29 Mar 2018 18:07:31 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id F11A5129D6; Thu, 29 Mar 2018 20:07:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id E48A511DDB; Thu, 29 Mar 2018 20:07:28 +0200 (CEST) Received: from [78.35.131.140] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.9) (envelope-from ) id 5abd2b60-02b7-7f0000012729-7f000001a604-1 for ; Thu, 29 Mar 2018 20:07:28 +0200 Received: from [192.168.178.68] (xdsl-78-35-131-140.netcologne.de [78.35.131.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Thu, 29 Mar 2018 20:07:27 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 85111, some more zero size stuff Message-ID: <7c4b20d0-7f21-632c-197f-7d5e89f0a61a@netcologne.de> Date: Thu, 29 Mar 2018 20:07:27 +0200 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 PR 85111, a regression introduced with my recent simplification patches. Seems like the zero-size saga has yet another chapter :-) Regression-tested. OK for trunk? Regards Thomas 2017-03-29 Thomas Koenig PR fortran/85111 * array.c (gfc_resolve_character_array_constructor): Early exit for zero-size arrays. * simplify.c (simplify_transformation_to_array): Exit early if the result size is zero. (simplify_minmaxloc_to_array): Likewise. 2017-03-29 Thomas Koenig PR fortran/85111 * gfortran.dg/zero_sized_10.f90: New test. Index: array.c =================================================================== --- array.c (revision 258845) +++ array.c (working copy) @@ -2003,6 +2003,20 @@ gfc_resolve_character_array_constructor (gfc_expr got_charlen: + /* Early exit for zero size arrays. */ + if (expr->shape) + { + mpz_t size; + HOST_WIDE_INT arraysize; + + gfc_array_size (expr, &size); + arraysize = mpz_get_ui (size); + mpz_clear (size); + + if (arraysize == 0) + return true; + } + found_length = -1; if (expr->ts.u.cl->length == NULL) Index: simplify.c =================================================================== --- simplify.c (revision 258845) +++ simplify.c (working copy) @@ -627,7 +627,7 @@ simplify_transformation_to_array (gfc_expr *result n += 1; } - done = false; + done = resultsize <= 0; base = arrayvec; dest = resultvec; while (!done) @@ -5304,7 +5304,7 @@ simplify_minmaxloc_to_array (gfc_expr *result, gfc n += 1; } - done = false; + done = resultsize <= 0; base = arrayvec; dest = resultvec; while (!done)