From patchwork Sun Mar 3 09:44:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1050828 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-497269-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine 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="dL1CvD9D"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="O6TH64Ky"; 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 44Byw30vDLz9s4Y for ; Sun, 3 Mar 2019 20:46:04 +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=fXVtl3tKOF8u3/nUyNt+60s3Nmc4EuwGly8Iugb22SIugT6O5z rD75M2xaOc0KpeLkFXhVFBSAjv3dS5/I155uMiNpurGU/LemOwvzFyO765mlwW1C mp4oqj3/7ow7+vkjkofNS1Rp/ERE0jQj/9yR1BE36MaaK2KTdv9bbRuLM= 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=thkJpHmLtgpejS7N0vVsPd50toU=; b=dL1CvD9DOMSMgYSEL954 2OBqElpFQV2kdkesOWgKN9B8duqUwsWZmpTH7xIMFsnWrdDgh/ZxBlb1ktfyHGa8 TQZDfQaVBcckWLZoUvmZ0qYmKvAhIoS3Ils2ZPoHvMYKGOjdTRhordBF5XGhLzW6 Wq9UiDSEcXYOcVz+mSsoxdQ= Received: (qmail 89481 invoked by alias); 3 Mar 2019 09:45:46 -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 89252 invoked by uid 89); 3 Mar 2019 09:45:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable version=3.3.2 spammy= X-HELO: cc-smtpout2.netcologne.de Received: from cc-smtpout2.netcologne.de (HELO cc-smtpout2.netcologne.de) (89.1.8.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 03 Mar 2019 09:45:05 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id CB4541263F; Sun, 3 Mar 2019 10:45:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1551606300; bh=nBN7wOCCZap9KHULndb1uOJP/tGSi568Os2pR6a+cgo=; h=To:From:Subject:Message-ID:Date:From; b=O6TH64KyyKc5Cf9zu85qd1/kcmcL5mkXUe3ZK7/pE7KQSUWPpzeTZVO0wM6C4YZDh gu+mo/qTcSH/+8gIt42lCXn4rbziTNfErBX4elVpDx3aqQAAgJQ35DFSv8SxreT3Ux 19Ov7zi+IBWGiPOfgvnDQgyxNuip0eOJj+I5gZfs6GbKu2GlOdOTigz7IDye7ryTet C9wYF9iHn4v5fJu5lXADg8FnLATsAIGjWo7CNDmIyS7qZA6YVRB6f1XJLXIVzl/r88 zM+/2T55W2syp99DFhaec//9dyhRN6rInDRcv3qPFqIHdf5KyD57RctDVNYpWBrOUc WQIjjtM2emTJA== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id BC86611D90; Sun, 3 Mar 2019 10:45:00 +0100 (CET) Received: from [2001:4dd7:50c3:0:7285:c2ff:fe6c:992d] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5c7ba21c-0bea-7f0000012729-7f000001d9dc-1 for ; Sun, 03 Mar 2019 10:45:00 +0100 Received: from [IPv6:2001:4dd7:50c3:0:7285:c2ff:fe6c:992d] (2001-4dd7-50c3-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd7:50c3:0:7285:c2ff:fe6c:992d]) (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; Sun, 3 Mar 2019 10:44:57 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 72714, ICE on invalid Message-ID: <139a19ae-78c7-f256-83c2-bcc190637862@netcologne.de> Date: Sun, 3 Mar 2019 10:44:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 Hello world, the attached patch fixes a 7/8/9 regression by rejecting an invalid expression in coarray allocation that led to an ICE. It also adds a few more checks. One point that is checked for is that, unlike normal arrays, coarrays cannot be empty. Regression-tested. OK for trunk and affected branches? Regards Thomas 2019-03-02 Thomas Koenig PR fortran/72714 * resolve.c (resolve_allocate_expr): Add some tests for coarrays. 2019-03-02 Thomas Koenig PR fortran/72714 * gfortran.dg/coarray_allocate_11.f90: New test. Index: resolve.c =================================================================== --- resolve.c (Revision 269260) +++ resolve.c (Arbeitskopie) @@ -7766,13 +7766,54 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code if (codimension) for (i = ar->dimen; i < ar->dimen + ar->codimen; i++) - if (ar->dimen_type[i] == DIMEN_THIS_IMAGE) - { - gfc_error ("Coarray specification required in ALLOCATE statement " - "at %L", &e->where); - goto failure; - } + { + switch (ar->dimen_type[i]) + { + case DIMEN_THIS_IMAGE: + gfc_error ("Coarray specification required in ALLOCATE statement " + "at %L", &e->where); + goto failure; + case DIMEN_RANGE: + if (ar->start[i] == 0 || ar->end[i] == 0) + { + /* If ar->stride[i] is NULL, we issued a previous error. */ + if (ar->stride[i] == NULL) + gfc_error ("Bad array specification in ALLOCATE statement " + "at %L", &e->where); + goto failure; + } + else if (gfc_dep_compare_expr (ar->start[i], ar->end[i]) == 1) + { + gfc_error ("Upper cobound is less than lower cobound at %L", + &ar->start[i]->where); + goto failure; + } + break; + + case DIMEN_ELEMENT: + if (ar->start[i]->expr_type == EXPR_CONSTANT) + { + gcc_assert (ar->start[i]->ts.type == BT_INTEGER); + if (mpz_cmp_si (ar->start[i]->value.integer, 1) < 0) + { + gfc_error ("Upper cobound is less than lower cobound " + " of 1 at %L", &ar->start[i]->where); + goto failure; + } + } + break; + + case DIMEN_STAR: + break; + + default: + gfc_error ("Bad array specification in ALLOCATE statement at %L", + &e->where); + goto failure; + + } + } for (i = 0; i < ar->dimen; i++) { if (ar->type == AR_ELEMENT || ar->type == AR_FULL)