[cfe-commits] r164569 - in /cfe/trunk: lib/AST/Expr.cpp test/SemaCXX/unused.cpp

Eli Friedman eli.friedman at gmail.com
Mon Sep 24 16:02:26 PDT 2012


Author: efriedma
Date: Mon Sep 24 18:02:26 2012
New Revision: 164569

URL: http://llvm.org/viewvc/llvm-project?rev=164569&view=rev
Log:
Handle C++ functional casts in a similar way to C-style casts in
unused expression warnings.  <rdar://problem/12359208>.


Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/test/SemaCXX/unused.cpp

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=164569&r1=164568&r2=164569&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Sep 24 18:02:26 2012
@@ -2019,6 +2019,7 @@
     R1 = getSourceRange();
     return true;
   }
+  case CXXFunctionalCastExprClass:
   case CStyleCastExprClass: {
     // Ignore an explicit cast to void unless the operand is a non-trivial
     // volatile lvalue.

Modified: cfe/trunk/test/SemaCXX/unused.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unused.cpp?rev=164569&r1=164568&r2=164569&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/unused.cpp (original)
+++ cfe/trunk/test/SemaCXX/unused.cpp Mon Sep 24 18:02:26 2012
@@ -34,3 +34,15 @@
     (void)y; // don't warn here, because it's a common pattern.
   }
 }
+
+// <rdar://problem/12359208>
+namespace AnonObject {
+  struct Foo {
+    Foo(const char* const message);
+    ~Foo();
+  };
+  void f() {
+    Foo("Hello World!");  // don't warn
+    int(1); // expected-warning {{expression result unused}}
+  }
+}





More information about the cfe-commits mailing list