[cfe-commits] r166468 - in /cfe/trunk: lib/AST/Expr.cpp test/SemaCXX/unused.cpp
Matt Beaumont-Gay
matthewbg at google.com
Mon Oct 22 23:15:26 PDT 2012
Author: matthewbg
Date: Tue Oct 23 01:15:26 2012
New Revision: 166468
URL: http://llvm.org/viewvc/llvm-project?rev=166468&view=rev
Log:
Fix -Wunused-value to not warn on expressions that have unresolved lookups due
to dependent arguments.
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=166468&r1=166467&r2=166468&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Oct 23 01:15:26 2012
@@ -1950,6 +1950,11 @@
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;
Modified: cfe/trunk/test/SemaCXX/unused.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unused.cpp?rev=166468&r1=166467&r2=166468&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/unused.cpp (original)
+++ cfe/trunk/test/SemaCXX/unused.cpp Tue Oct 23 01:15:26 2012
@@ -46,3 +46,18 @@
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 <typename T>
+ struct Bar {
+ void f(T t) {
+ Foo(t, 0); // no warning
+ }
+ };
+}
More information about the cfe-commits
mailing list