From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31508 invoked by alias); 17 Jan 2019 01:10:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 31481 invoked by uid 89); 17 Jan 2019 01:10:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=signatures, interest X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Jan 2019 01:10:15 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1gjwCD-0002Pq-3F from joseph_myers@mentor.com ; Wed, 16 Jan 2019 17:10:13 -0800 Received: from digraph.polyomino.org.uk (137.202.0.90) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Thu, 17 Jan 2019 01:10:09 +0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.90_1) (envelope-from ) id 1gjwC8-0003Ya-UN; Thu, 17 Jan 2019 01:10:08 +0000 Date: Thu, 17 Jan 2019 01:10:00 -0000 From: Joseph Myers To: Martin Sebor CC: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH] detect references to statics in inline function signatures (PR 88718) In-Reply-To: <88486280-8219-03fa-117f-6ce97a7e8180@gmail.com> Message-ID: References: <82358938-a70e-2734-3dfe-b7460d7e89d7@gmail.com> <88486280-8219-03fa-117f-6ce97a7e8180@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2019-01/txt/msg00970.txt.bz2 On Wed, 16 Jan 2019, Martin Sebor wrote: > + /* Iterate over tentative records (all those at the head of the list > + with a null FUNCTION) and either associate them with DECL when ADD > + is set or remove them from it otherwise. */ > + for (c_inline_static *csi = c_inline_statics, *last = csi; > + csi; csi = csi->next) (Here we start with last == c_inline_statics.) > + if (add) > + { > + if (csi->static_decl) > + csi->function = decl; > + } I don't see any way in which csi->static_decl can be NULL (both callers of record_inline_static appear only to use non-NULL values for that argument, and it being non-NULL seems implicit in the semantics of the function given by the comment above it). That is, I don't see the use of the inner "if" here. > + if (last == c_inline_statics) > + c_inline_statics = last = csi->next; > + else > + last->next = csi->next; Here, if either last or c_inline_statics changes, they remain the same, so I don't see how they can ever be different. So I don't see the need for having the variable last at all, or the conditional "if (last == c_inline_statics)". It's always the case that, if removing entries from the list, it's some number of leading entries, so I'd expect just "c_inline_statics = csi->next;" to be sufficient for removing an entry. > + /* FUNCTION is unset for a declaration whose signature references > + a static variable and for which a definition wasn't provided. */ > + if (!csi->function) > + continue; But those should have been removed after the declaration in all cases via a call to update_tentative_inline_static. So why is this conditional needed here? > + /* Only extern functions are of interest. STATIC_DECL is null > + for inline functions that have been defined that contain > + no references to statics (but whose subsequent declarations > + might). */ > + if (!DECL_EXTERNAL (csi->function) > + || !csi->static_decl) > + continue; As above, I don't see the need for the !csi->static_decl check, as csi->static_decl should never be NULL. -- Joseph S. Myers joseph@codesourcery.com