From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 2F46B385842B; Wed, 22 Feb 2023 17:23:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F46B385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677086630; bh=C6FGx7w+GGKbbq7UnesYWFIEzivtl+U2QqnCrbCkfYg=; h=From:To:Subject:Date:From; b=pmsfx8nO04IJx37aJsLNRJeSkAX3m4+rsK5CniaPyNwLFVMb2q+k6bY8++NXMAi/d JSS5V+dDIziZzAqeMFzVzwULNbAYViOtCHTjM5FFcPcVjJXa6iBOoNgQL3iXj4XfjJ QTCCIUso8ATRzuJgY9eDYAMNswdwjkMlq5JgObbA= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] [c++] suppress redundant null-addr warn in pfn from pmfn X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: 811faac4e564b75c783a1377912ce0431131bdce X-Git-Newrev: f62e89fd7a4b182eb554e05d17ad558426d399b1 Message-Id: <20230222172350.2F46B385842B@sourceware.org> Date: Wed, 22 Feb 2023 17:23:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f62e89fd7a4b182eb554e05d17ad558426d399b1 commit f62e89fd7a4b182eb554e05d17ad558426d399b1 Author: Alexandre Oliva Date: Wed Feb 22 12:33:21 2023 -0300 [c++] suppress redundant null-addr warn in pfn from pmfn When TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta, when we warn about comparing a pointer-to-member-function with NULL, we also warn about comparing the pointer-to-function extracted from it with NULL, which is redundant. Suppress the redundant warning. for gcc/cp/ChangeLog * typeck.cc (cp_build_binary_op): Suppress redundant warning for pfn null test in pmfn test with vbit-in-delta. Diff: --- gcc/cp/typeck.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 4afb5e4f0d4..d5a3e501d8e 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -5780,11 +5780,18 @@ cp_build_binary_op (const op_location_t &location, pfn0 = pfn_from_ptrmemfunc (op0); delta0 = delta_from_ptrmemfunc (op0); - e1 = cp_build_binary_op (location, - EQ_EXPR, - pfn0, - build_zero_cst (TREE_TYPE (pfn0)), - complain); + { + /* If we will warn below about a null-address compare + involving the orig_op0 ptrmemfunc, we'd likely also + warn about the pfn0's null-address compare, and + that would be redundant, so suppress it. */ + warning_sentinel ws (warn_address); + e1 = cp_build_binary_op (location, + EQ_EXPR, + pfn0, + build_zero_cst (TREE_TYPE (pfn0)), + complain); + } e2 = cp_build_binary_op (location, BIT_AND_EXPR, delta0,