From: Matt Beaumont-Gay Date: Tue, 23 Oct 2012 06:15:26 +0000 (+0000) Subject: Fix -Wunused-value to not warn on expressions that have unresolved lookups due X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84c3b9745f813a784b5d8ce77f2785750523d9eb;p=clang Fix -Wunused-value to not warn on expressions that have unresolved lookups due to dependent arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166468 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 694325af22..3c8cbb56a0 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1950,6 +1950,11 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc, return false; } + // If we don't know precisely what we're looking at, let's not warn. + case UnresolvedLookupExprClass: + case CXXUnresolvedConstructExprClass: + return false; + case CXXTemporaryObjectExprClass: case CXXConstructExprClass: return false; diff --git a/test/SemaCXX/unused.cpp b/test/SemaCXX/unused.cpp index b9877a1ba4..fbaf8c8bf3 100644 --- a/test/SemaCXX/unused.cpp +++ b/test/SemaCXX/unused.cpp @@ -46,3 +46,18 @@ namespace AnonObject { int(1); // expected-warning {{expression result unused}} } } + +// Test that constructing an object (which may have side effects) with +// constructor arguments which are dependent doesn't produce an unused value +// warning. +namespace UnresolvedLookup { + struct Foo { + Foo(int i, int j); + }; + template + struct Bar { + void f(T t) { + Foo(t, 0); // no warning + } + }; +}