Patchwork [C++] PR 14710 (add -Wuseless-cast)

login
register
mail settings
Submitter Paolo Carlini
Date March 19, 2012, 5:43 p.m.
Message ID <4F677025.9030203@oracle.com>
Download mbox | patch
Permalink /patch/147599/
State New
Headers show

Comments

Paolo Carlini - March 19, 2012, 5:43 p.m.
On 03/19/2012 03:59 PM, Jason Merrill wrote:
> OK.
Thanks. I committed the patch. I'm going to add, as obvious, the 
following few additional tests, which my previous iteration got wrong.

Paolo.

//////////////////
2012-03-19  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/warn/Wuseless-cast.C: Extend.

Patch

Index: testsuite/g++.dg/warn/Wuseless-cast.C
===================================================================
--- testsuite/g++.dg/warn/Wuseless-cast.C	(revision 185528)
+++ testsuite/g++.dg/warn/Wuseless-cast.C	(working copy)
@@ -58,6 +58,8 @@  template<typename T>
     dynamic_cast<A&>(t);
   }
 
+A prvalue();
+
 void f()
 {
   int n; 
@@ -90,6 +92,10 @@  void f()
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
   (int&&)(42);
   static_cast<int&&>(42);
+
+  (A&&)(prvalue());
+  const_cast<A&&>(prvalue());
+  static_cast<A&&>(prvalue());
 #endif
 
   A a;