From patchwork Tue Jul 23 21:42:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pchang9@cs.wisc.edu X-Patchwork-Id: 261223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2EB532C00CC for ; Wed, 24 Jul 2013 07:42:56 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:subject:from:to:mime-version:content-type; q= dns; s=default; b=mk9fS/aycktJsBXyvk0OKy5FPiV9XRuFimwhhC6Y8P6Rrq AiZBW2uPbF1bwnpKkRcTlpkIhyDuYpCha/if2sbFjU7Cc61sXK1ELykXF52HEVZ1 RXNLchVLQOimx+MQ4TOmtT4LU1a5hsPBO+HfP32tmrxhPS64tf8gixGVNLKxo= 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 :message-id:date:subject:from:to:mime-version:content-type; s= default; bh=mFB8lrOyh9y8R/EZQhel6WyKIDA=; b=E0g5jw8GW6Kc4FwImTr/ XFsv2l0avxxM/4GhotgxVZzDv1PqT9eC96qWyj/9xWcFRu7AB+AMaQ5S/SIz4aS+ pK7/bLT2gUwgR568a/90Hhd6AJcSa0Iv5Zoc/8ccQ59gxoJBpcUhvENreVDP0Inv aQCZG8p+uxLKQ0Hm8LOySiI= Received: (qmail 32545 invoked by alias); 23 Jul 2013 21:42:50 -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 32519 invoked by uid 89); 23 Jul 2013 21:42:50 -0000 X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_W, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from Unknown (HELO sandstone.cs.wisc.edu) (128.105.6.39) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 23 Jul 2013 21:42:49 +0000 Received: from webmail.cs.wisc.edu (george.cs.wisc.edu [128.105.7.110]) by sandstone.cs.wisc.edu (8.14.1/8.14.1) with ESMTP id r6NLgfOT021328; Tue, 23 Jul 2013 16:42:41 -0500 Received: from 146.151.118.255 (SquirrelMail authenticated user pchang9) by webmail.cs.wisc.edu with HTTP; Tue, 23 Jul 2013 16:42:41 -0500 Message-ID: <572c52f3beb83506456fb925b2478aee.squirrel@webmail.cs.wisc.edu> Date: Tue, 23 Jul 2013 16:42:41 -0500 Subject: [Patch, PR 57791] Waste work in gfc_check_pointer_assign() From: pchang9@cs.wisc.edu To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org User-Agent: SquirrelMail/1.4.22 MIME-Version: 1.0 X-Virus-Found: No Hi, The problem appears in revision 201034 in version 4.9. I attached a one-line patch that fixes it. I also reported this problem at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57791 Bootstrap and regression-tested on x86_64-linux. In method "gfc_check_pointer_assign()" in expr.c, the loop on line 3763 should break immediately after "warn" is set to "true". 2013-07-23 Chang * expr.c (gfc_check_pointer_assign): Exit loop after setting warn. -Chang Index: gcc/fortran/expr.c =================================================================== --- gcc/fortran/expr.c (revision 201034) +++ gcc/fortran/expr.c (working copy) @@ -3764,7 +3764,10 @@ ns && ns->proc_name && ns->proc_name->attr.flavor != FL_PROCEDURE; ns = ns->parent) if (ns->parent == lvalue->symtree->n.sym->ns) - warn = true; + { + warn = true; + break; + } if (warn) gfc_warning ("Pointer at %L in pointer assignment might outlive the " Index: gcc/fortran/expr.c =================================================================== --- gcc/fortran/expr.c (revision 201034) +++ gcc/fortran/expr.c (working copy) @@ -3764,7 +3764,10 @@ ns && ns->proc_name && ns->proc_name->attr.flavor != FL_PROCEDURE; ns = ns->parent) if (ns->parent == lvalue->symtree->n.sym->ns) - warn = true; + { + warn = true; + break; + } if (warn) gfc_warning ("Pointer at %L in pointer assignment might outlive the "