]> granicus.if.org Git - clang/commitdiff
Fix a little crasher in friend decls. Thanks again to Eli for finding this.
authorJohn McCall <rjmccall@apple.com>
Wed, 2 Sep 2009 01:07:03 +0000 (01:07 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 2 Sep 2009 01:07:03 +0000 (01:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80748 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.h
test/CXX/temp/temp.decls/temp.friend/p1.cpp

index 63d2831fab1aff0be4c12aee38c7ec081788bcbb..e2205d6df54c3aa7e76d2a1973de431953dc3894 100644 (file)
@@ -715,10 +715,11 @@ public:
   /// Finds the scope corresponding to the given decl context, if it
   /// happens to be an enclosing scope.  Otherwise return NULL.
   Scope *getScopeForDeclContext(Scope *S, DeclContext *DC) {
-    DC = DC->getPrimaryContext();
+    DeclContext *TargetDC = DC->getPrimaryContext();
     do {
-      if (((DeclContext*) S->getEntity())->getPrimaryContext() == DC)
-        return S;
+      if (DeclContext *ScopeDC = (DeclContext*) S->getEntity())
+        if (ScopeDC->getPrimaryContext() == TargetDC)
+          return S;
     } while ((S = S->getParent()));
 
     return NULL;
index 4f0037d47081d0ea9d5acce49f900c21519f0c10..4434d483890293b34133c4aba264302355a68dc7 100644 (file)
@@ -29,6 +29,10 @@ public:
   }
 };
 
+class A {
+  template <typename T> friend bool iszero(const A &a) throw();
+};
+
 int calc1() {
   Num<int> left = -1;
   Num<int> right = 1;