From patchwork Sun Aug 27 20:05:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 806301 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-460994-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="eDEmoEXP"; 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 3xgQqz1k9zz9s8V for ; Mon, 28 Aug 2017 06:05:33 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=BWkwIB/rMBAa9AG/AT8GAd8PUpgivwEiiNVF5mslT6S3Te vlYx9p/PSBHqeqJ0Bn3S34HlsLDhZ47JXqt7JZUo+lw4QrhuAqDQMZTC7N1veTyQ 4UDu/iJ9E1SkCSsrxAW7lIzmsmQH3ezKqZ34wFHUxVvnm2QREewocTdRmtJf0= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=yi5LQlksNTDGqZCfwL4zwRxL3p8=; b=eDEmoEXP/Fxe9TUXEwmi oJ9spAcB1Dh/361DEKXvb/tNPrdVuTa9JmD363Xp0i2VORijIqhR0Bvn9t0DKlEK lGPu3+0GTCkcsUX1sIfrTXxcEtCWw6YXqGvfeXIUmRtjecWLg53KwlVET2QVUTTX CzVRxCF1uZWZGdPVbr69oic= Received: (qmail 102782 invoked by alias); 27 Aug 2017 20:05:20 -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 102756 invoked by uid 89); 27 Aug 2017 20:05:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=thrown, Hx-languages-length:2030, sk:janus@g, janus@gcc.gnu.org X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-yw0-f193.google.com Received: from mail-yw0-f193.google.com (HELO mail-yw0-f193.google.com) (209.85.161.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 27 Aug 2017 20:05:17 +0000 Received: by mail-yw0-f193.google.com with SMTP id s143so2379070ywg.4; Sun, 27 Aug 2017 13:05:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=zUXNfgVFFXBp4oJYy62am4nymdt7OXEdX+XqhmoJ9uY=; b=mKxT/pet+A79UeJJhCQSSyMpRwUOzIFQk784AFXxwp22HmTMAU5aeHvOg9GnzJ8wn6 H2NbdHwLVEGdq4xzsm6KHBMnWIG3MQAWV4YhPLKKAMst2z1gMm01K4x3d7DubRbV03Lt p1wy91FrBGULhT9J341Joer4TOyOqXmnorm6GehhZ693IiKD8R9dsH6HbhMAGTZ2IDNh qTdDNpb2Qcc7eYbkzmMXj0aSvcyMDYC+wWDFv6ElkfUGfdXqupkcLGY+C0lL9Xa1X0OQ T/qWxmADPkkuj3Ol05Jv74dV84mMPa8Jd4mnbrjs97mxlPdqNsLhvLRJer6N5AJGG82J 3V7Q== X-Gm-Message-State: AHYfb5jNIjuubQy2Q4BnRqX5uIEHOO3b2vTWV1uvZYaVmbiXsup4PuC2 J6qAMvnyLomEHD5IfopqeHV6e4LRgRnC X-Received: by 10.37.125.199 with SMTP id y190mr4138837ybc.358.1503864315527; Sun, 27 Aug 2017 13:05:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.13.203.196 with HTTP; Sun, 27 Aug 2017 13:05:14 -0700 (PDT) From: Janus Weil Date: Sun, 27 Aug 2017 22:05:14 +0200 Message-ID: Subject: [Patch, Fortran] PR 81770: [5/6/7 Regression] Bogus warning: Pointer in pointer assignment might outlive the pointer target To: gfortran , gcc-patches Hi all, the attached patch fixes a bogus warning. The purpose of the warning is to detect cases where a pointer lives longer than its target. If the target itself is (1) a pointer or (2) a component of a DT pointer, we do not know about the lifetime of the target at compile time and no warning should be thrown. The existing check only handles case (1) and my patch adds the handling of case (2). Regtestes cleanly on x86_64-linux-gnu. Ok for trunk and the release branches? Cheers, Janus 2017-08-27 Janus Weil PR fortran/81770 * expr.c (gfc_check_pointer_assign): Improve the check whether pointer may outlive pointer target. 2017-08-27 Janus Weil PR fortran/81770 * gfortran.dg/warn_target_lifetime_4.f90: New testcase. Index: gcc/fortran/expr.c =================================================================== --- gcc/fortran/expr.c (revision 251368) +++ gcc/fortran/expr.c (working copy) @@ -3806,7 +3806,8 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_ex if (warn_target_lifetime && rvalue->expr_type == EXPR_VARIABLE && !rvalue->symtree->n.sym->attr.save - && !attr.pointer && !rvalue->symtree->n.sym->attr.host_assoc + && !rvalue->symtree->n.sym->attr.pointer && !attr.pointer + && !rvalue->symtree->n.sym->attr.host_assoc && !rvalue->symtree->n.sym->attr.in_common && !rvalue->symtree->n.sym->attr.use_assoc && !rvalue->symtree->n.sym->attr.dummy)