From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31264 invoked by alias); 19 Dec 2008 23:16:29 -0000 Received: (qmail 31255 invoked by uid 22791); 19 Dec 2008 23:16:29 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,KAM_MX,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Dec 2008 23:15:32 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id mBJNFUjc005130; Fri, 19 Dec 2008 18:15:30 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mBJNFT8F007696; Fri, 19 Dec 2008 18:15:29 -0500 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.2/8.14.2/Submit) id mBJNFTRv018498; Sat, 20 Dec 2008 00:15:29 +0100 Date: Fri, 19 Dec 2008 23:38:00 -0000 From: Jakub Jelinek To: Jason Merrill Cc: Manuel =?iso-8859-1?B?TPNwZXotSWLh8WV6?= , Gcc Patch List Subject: Re: PR c++/36921 [4.3/4.4 Regression] warning "comparison does not have mathematical meaning" is not correct for overloaded operators that do not return boolean Message-ID: <20081219231529.GK17496@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <6c33472e0810250750y33c10265g3195e8613de1b1fc@mail.gmail.com> <20081025162735.GM14706@tyan-ft48-01.lab.bos.redhat.com> <6c33472e0811041414l57b4b98ibb84350dcf60117f@mail.gmail.com> <494C2488.7000002@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <494C2488.7000002@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes 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 X-SW-Source: 2008-12/txt/msg01083.txt.bz2 On Fri, Dec 19, 2008 at 05:47:36PM -0500, Jason Merrill wrote: > I agree that we don't want to warn for this code, but I think the right > place to fix it is in warn_about_parentheses; your patch will also > disable the parenthesis warnings for overloaded comparison ops, which we > don't want, since precedence is the same regardless of the return type. warn_about_parentheses isn't passed the whole expr though, so it can't check its type. Manu's patch just stopped calling warn_about_parentheses for (non-bool returning overloaded) comparison other than ==/!=, but when code has tcc_comparison class other than EQ_EXPR/NE_EXPR, default: if (TREE_CODE_CLASS (code) == tcc_comparison && ((TREE_CODE_CLASS (code_left) == tcc_comparison && code_left != NE_EXPR && code_left != EQ_EXPR) || (TREE_CODE_CLASS (code_right) == tcc_comparison && code_right != NE_EXPR && code_right != EQ_EXPR))) warning (OPT_Wparentheses, "comparisons like % do not " "have their mathematical meaning"); is the only thing warn_about_parentheses warns about. We already have a precedent in build_x_binary_op for avoiding warn_about_parentheses call in other situations, in particular about obj << x + y. Jakub