From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21752 invoked by alias); 18 Dec 2017 02:04:43 -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 21742 invoked by uid 89); 18 Dec 2017 02:04:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Dec 2017 02:04:42 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F76337E80; Mon, 18 Dec 2017 02:04:40 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-35.phx2.redhat.com [10.3.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id F186E17C20; Mon, 18 Dec 2017 02:04:38 +0000 (UTC) From: David Malcolm To: Jason Merrill Cc: Nathan Sidwell , Jakub Jelinek , Richard Biener , gcc-patches List , David Malcolm Subject: [v2 of PATCH 06/14] Strip location wrappers in operand_equal_p Date: Mon, 18 Dec 2017 02:04:00 -0000 Message-Id: <1513562874-38507-1-git-send-email-dmalcolm@redhat.com> In-Reply-To: <8533d574-bf9b-54f6-2683-bcd6fc813b56@redhat.com> References: <8533d574-bf9b-54f6-2683-bcd6fc813b56@redhat.com> X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg01142.txt.bz2 On Mon, 2017-12-11 at 18:37 -0500, Jason Merrill wrote: > On 11/10/2017 04:45 PM, David Malcolm wrote: > > gcc/c-family/ChangeLog: > > * c-warn.c (sizeof_pointer_memaccess_warning): Strip any > > location > > wrappers from src and dest. > > Here the existing calls to tree_strip_nop_conversions ought to > handle > the wrappers. They don't; when EXP is a VIEW_CONVERT_EXPR wrapper around a VAR_DECL... 11887 static inline bool 11888 tree_nop_conversion (const_tree exp) 11889 { 11890 tree outer_type, inner_type; 11891 11892 if (!CONVERT_EXPR_P (exp) 11893 && TREE_CODE (exp) != NON_LVALUE_EXPR) 11894 return false; ...tree_nop_conversion bails out at this "return false;", and hence tree_strip_nop_conversions simply returns the wrapper that was passed in. I tried adding fold_for_warn on src and dest, but it doesn't do quite the right thing, as FAIL: c-c++-common/Wsizeof-pointer-memaccess2.c -std=gnu++98 (test for warnings, line 482) FAIL: c-c++-common/Wsizeof-pointer-memaccess2.c -std=gnu++98 (test for warnings, line 483) FAIL: c-c++-common/Wsizeof-pointer-memaccess2.c -std=gnu++98 (test for warnings, line 484) ...due to "src" changing from being a VAR_DECL to being its STRING_CST value after the fold_for_warn, So one approach for Wsizeof-pointer-memaccess*.c is the patch I posted ("[PATCH 06/14] Fix Wsizeof-pointer-memaccess*.c"), which ensures that any wrappers have been stripped before the call to operand_equal_p in sizeof_pointer_memaccess_warning. Alternatively, here's a patch which strips wrappers in operand_equal_p. FWIW I prefer doing it in sizeof_pointer_memaccess_warning, rather than touching operand_equal_p. What do you think? Successfully bootstrapped®rtested on x86_64-pc-linux-gnu, as part of the kit. gcc/ChangeLog: * fold-const.c (operand_equal_p): Strip any location wrappers, before computing hashes. --- gcc/fold-const.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 0f11076..2b938900 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2804,6 +2804,9 @@ combine_comparisons (location_t loc, int operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) { + STRIP_ANY_LOCATION_WRAPPER (arg0); + STRIP_ANY_LOCATION_WRAPPER (arg1); + /* When checking, verify at the outermost operand_equal_p call that if operand_equal_p returns non-zero then ARG0 and ARG1 has the same hash value. */ -- 1.8.5.3