From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16234 invoked by alias); 17 Mar 2016 00:43:46 -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 16218 invoked by uid 89); 17 Mar 2016 00:43:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=significance, Hx-languages-length:1388, HContent-Transfer-Encoding:8bit X-HELO: mail-qk0-f172.google.com Received: from mail-qk0-f172.google.com (HELO mail-qk0-f172.google.com) (209.85.220.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 17 Mar 2016 00:43:43 +0000 Received: by mail-qk0-f172.google.com with SMTP id o6so28920099qkc.2 for ; Wed, 16 Mar 2016 17:43:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=QUg/+FTlETLi0M1nUJXIp67xgTpB57OfxWV8epqNXz8=; b=KYQMNDyQ/P30AqpE17q6jBABc8zQWpaTQf+8TuCQeY8qKFY8O8VgF2MmrDel65N3EG JXrX4zGL2OmM/5hON3nvQWJMcrFuC+o0ESbz4hrzviS5rnotGTr5E9TY2hBAE+l+PJ2O llyfeo+kY8d+0OMUCoL2DMhWhZ4b65Rzb9lI3ohW8p8H8ZDbd/TqXm5T3yDQdZvAuRsl pDps0pUzHTuDr0BH0XbCREg4J7UCV3V/xrnnDi4bVso8R0v8h02ZL0W24Y8lXfsoMRQz ZMnXlqUh4r1MBciazsc9vzlrCWOtfOy9wpClS08fWdlPxCEykkxoX8aj0oMU2AANoeaf FgbA== X-Gm-Message-State: AD7BkJIlgIeFvJKVFT3LEeQ2PCHwrXtF5UhUg1UUDWBsO8XRGIeROEJceKistwxqh0mkRQ== X-Received: by 10.55.74.141 with SMTP id x135mr10198575qka.20.1458175421862; Wed, 16 Mar 2016 17:43:41 -0700 (PDT) Received: from [192.168.0.26] (97-122-182-246.hlrn.qwest.net. [97.122.182.246]) by smtp.gmail.com with ESMTPSA id b103sm2715789qge.2.2016.03.16.17.43.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Mar 2016 17:43:41 -0700 (PDT) Subject: Re: C++ PATCH to fix missing warning (PR c++/70194) To: Marek Polacek , Jason Merrill References: <20160315104120.GC10006@redhat.com> <20160315105618.GT3017@tucnak.redhat.com> <20160315120918.GD10006@redhat.com> <56E86580.70800@redhat.com> <20160316144552.GG10006@redhat.com> Cc: Jakub Jelinek , GCC Patches From: Martin Sebor Message-ID: <56E9FDBB.5070903@gmail.com> Date: Thu, 17 Mar 2016 00:43:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20160316144552.GG10006@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg00967.txt.bz2 > @@ -3974,6 +3974,38 @@ build_vec_cmp (tree_code code, tree type, > return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); > } > > +/* Possibly warn about an address never being NULL. */ > + > +static void > +warn_for_null_address (location_t location, tree op, tsubst_flags_t complain) > +{ ... > + if (TREE_CODE (cop) == ADDR_EXPR > + && decl_with_nonnull_addr_p (TREE_OPERAND (cop, 0)) > + && !TREE_NO_WARNING (cop)) > + warning_at (location, OPT_Waddress, "the address of %qD will never " > + "be NULL", TREE_OPERAND (cop, 0)); > + > + if (CONVERT_EXPR_P (op) > + && TREE_CODE (TREE_TYPE (TREE_OPERAND (op, 0))) == REFERENCE_TYPE) > + { > + tree inner_op = op; > + STRIP_NOPS (inner_op); > + > + if (DECL_P (inner_op)) > + warning_at (location, OPT_Waddress, > + "the compiler can assume that the address of " > + "%qD will never be NULL", inner_op); Since I noted the subtle differences between the phrasing of the various -Waddress warnings in the bug, I have to ask: what is the significance of the difference between the two warnings here? Would it not be appropriate to issue the first warning in the latter case? Or perhaps even use the same text as is already used elsewhere: "the address of %qD will always evaluate as ‘true’" (since it may not be the macro NULL that's mentioned in the expression). Martin