diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-09-24 23:02:26 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-09-24 23:02:26 +0000 |
commit | 6319917b5021e9602389b49ca4f245d235e9b90a (patch) | |
tree | d30e950c9dd1abfebe58c4fb54bc2e6953fc15f2 | |
parent | 7935dde8e4dd8089536e28d51a0864252064ecd3 (diff) |
Handle C++ functional casts in a similar way to C-style casts in
unused expression warnings. <rdar://problem/12359208>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164569 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Expr.cpp | 1 | ||||
-rw-r--r-- | test/SemaCXX/unused.cpp | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 74308a0093..30342585c8 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -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. diff --git a/test/SemaCXX/unused.cpp b/test/SemaCXX/unused.cpp index 54898c828e..b9877a1ba4 100644 --- a/test/SemaCXX/unused.cpp +++ b/test/SemaCXX/unused.cpp @@ -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}} + } +} |