This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ Patch] PR 14710 (add -Wuseless-cast)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]