[cfe-commits] r101112 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/CXX/class.access/class.friend/p1.cpp

John McCall rjmccall at apple.com
Mon Apr 12 18:44:10 PDT 2010


Author: rjmccall
Date: Mon Apr 12 20:44:10 2010
New Revision: 101112

URL: http://llvm.org/viewvc/llvm-project?rev=101112&view=rev
Log:
Don't try to find a scope corresponding to the search DC for an unfound
friend declaration;  this used to be important but is now just a waste of time
plus an unreasonable assertion.  Fixes PR6174.


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/CXX/class.access/class.friend/p1.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=101112&r1=101111&r2=101112&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Apr 12 20:44:10 2010
@@ -4930,14 +4930,6 @@
       //   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.

Modified: cfe/trunk/test/CXX/class.access/class.friend/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.friend/p1.cpp?rev=101112&r1=101111&r2=101112&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/class.friend/p1.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.friend/p1.cpp Mon Apr 12 20:44:10 2010
@@ -192,3 +192,22 @@
     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; }
+    };
+  }
+}





More information about the cfe-commits mailing list