diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2012-03-14 20:41:00 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2012-03-14 20:41:00 +0000 |
commit | 5a7120cf82b5f0110cb70aacad850c594a55b378 (patch) | |
tree | 038ec61c24a410cc408d8c4c0dd9a710638d2875 | |
parent | d53e877ddf885da28aa4668148a5f0ce0045ab54 (diff) |
When emitting a diagnostic about two-phase name lookup, don't do useless
qualified name lookups into transparent contexts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152739 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 3 | ||||
-rw-r--r-- | test/SemaCXX/warn-unused-value.cpp | 19 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index fe999b1599..b93fb093fa 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -9244,6 +9244,9 @@ DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc, return false; for (DeclContext *DC = SemaRef.CurContext; DC; DC = DC->getParent()) { + if (DC->isTransparentContext()) + continue; + SemaRef.LookupQualifiedName(R, DC); if (!R.empty()) { diff --git a/test/SemaCXX/warn-unused-value.cpp b/test/SemaCXX/warn-unused-value.cpp index 80298ec666..1c0263c581 100644 --- a/test/SemaCXX/warn-unused-value.cpp +++ b/test/SemaCXX/warn-unused-value.cpp @@ -30,3 +30,22 @@ void b(Foo f1, Foo f2) { } #undef NOP } + +namespace test2 { + extern "C" { + namespace std { + template<typename T> struct basic_string { + struct X {}; + void method() const { + X* x; + &x[0]; // expected-warning {{expression result unused}} + } + }; + typedef basic_string<char> string; + void func(const std::string& str) { + str.method(); // expected-note {{in instantiation of member function}} + } + } + } +} + |