]> granicus.if.org Git - clang/commitdiff
When emitting a diagnostic about two-phase name lookup, don't do useless
authorNick Lewycky <nicholas@mxc.ca>
Wed, 14 Mar 2012 20:41:00 +0000 (20:41 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Wed, 14 Mar 2012 20:41:00 +0000 (20:41 +0000)
qualified name lookups into transparent contexts.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152739 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/warn-unused-value.cpp

index fe999b159987139894fdda8d8ebc3648ebcb8bbf..b93fb093fa3ee51db2fc3e6f5c5ea3d1fe16c7f7 100644 (file)
@@ -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()) {
index 80298ec6664a8820f70a41c17e7ab7591dc40601..1c0263c581c188d22c4d058b492708d1fcb0d82c 100644 (file)
@@ -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}}
+      }
+    } 
+  }
+}
+