Handle C++ functional casts in a similar way to C-style casts in
authorEli Friedman <eli.friedman@gmail.com>
Mon, 24 Sep 2012 23:02:26 +0000 (23:02 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 24 Sep 2012 23:02:26 +0000 (23:02 +0000)
unused expression warnings.  <rdar://problem/12359208>.

llvm-svn: 164569

clang/lib/AST/Expr.cpp
clang/test/SemaCXX/unused.cpp

index 74308a0..3034258 100644 (file)
@@ -2019,6 +2019,7 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
     R1 = getSourceRange();
     return true;
   }
+  case CXXFunctionalCastExprClass:
   case CStyleCastExprClass: {
     // Ignore an explicit cast to void unless the operand is a non-trivial
     // volatile lvalue.
index 54898c8..b9877a1 100644 (file)
@@ -34,3 +34,15 @@ namespace derefvolatile {
     (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}}
+  }
+}