]> granicus.if.org Git - clang/commitdiff
Don't try to find a scope corresponding to the search DC for an unfound
authorJohn McCall <rjmccall@apple.com>
Tue, 13 Apr 2010 01:44:10 +0000 (01:44 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 13 Apr 2010 01:44:10 +0000 (01:44 +0000)
friend declaration;  this used to be important but is now just a waste of time
plus an unreasonable assertion.  Fixes PR6174.

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

lib/Sema/SemaDecl.cpp
test/CXX/class.access/class.friend/p1.cpp

index a4d86512125eb61bf2f4887d1bfdccbbcecfc587..171bee66ca20c513c37cf52dac43ca0bbcceba87 100644 (file)
@@ -4930,14 +4930,6 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
       //   class or function, the friend class or function is a member of
       //   the innermost enclosing namespace.
       SearchDC = SearchDC->getEnclosingNamespaceContext();
-
-      // Look up through our scopes until we find one with an entity which
-      // matches our declaration context.
-      while (S->getEntity() &&
-             ((DeclContext *)S->getEntity())->getPrimaryContext() != SearchDC) {
-        S = S->getParent();
-        assert(S && "No enclosing scope matching the enclosing namespace.");
-      }
     }
 
     // In C++, look for a shadow friend decl.
index 7ea4f078d205ccd40103996310f9a91c8bf5ac56..88cbe4f4cddecda36b8eaec1825a80b47ae2ca71 100644 (file)
@@ -192,3 +192,22 @@ namespace test4 {
     return a == b; // expected-note {{requested here}}
   }
 }
+
+
+// PR6174
+namespace test5 {
+  namespace ns {
+    class A;
+  }
+
+  class ns::A {
+  private: int x;
+    friend class B;
+  };
+
+  namespace ns {
+    class B {
+      int test(A *p) { return p->x; }
+    };
+  }
+}