From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15037 invoked by alias); 19 Mar 2012 13:17:37 -0000 Received: (qmail 15028 invoked by uid 22791); 19 Mar 2012 13:17:36 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Mar 2012 13:17:08 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2JDH70v022107 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Mar 2012 09:17:07 -0400 Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2JDH7Uf000758; Mon, 19 Mar 2012 09:17:07 -0400 Message-ID: <4F6731D2.7080909@redhat.com> Date: Mon, 19 Mar 2012 13:17:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 To: Paolo Carlini CC: "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 14710 (add -Wuseless-cast) References: <4F63B3DF.8060701@oracle.com> <4F64B5E5.2020502@redhat.com> <4F66001D.9030500@oracle.com> In-Reply-To: <4F66001D.9030500@oracle.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 2012-03/txt/msg01254.txt.bz2 On 03/18/2012 11:32 AM, Paolo Carlini wrote: > + if ((TREE_CODE (type) == REFERENCE_TYPE > + && lvalue_p (expr) > + && same_type_p (TREE_TYPE (expr), TREE_TYPE (type))) > + || same_type_p (TREE_TYPE (expr), type)) > + warning (OPT_Wuseless_cast, "useless cast to type %qT", type); I think instead of just lvalue_p (expr) you want TYPE_REF_IS_RVALUE (type) ? xvalue_p (expr) : real_lvalue_p (expr) where xvalue_p is a new function that just does return lvalue_kind (expr) == clk_rvalueref; Jason