[cfe-commits] r80748 - in /cfe/trunk: lib/Sema/Sema.h test/CXX/temp/temp.decls/temp.friend/p1.cpp

John McCall rjmccall at apple.com
Tue Sep 1 18:07:03 PDT 2009


Author: rjmccall
Date: Tue Sep  1 20:07:03 2009
New Revision: 80748

URL: http://llvm.org/viewvc/llvm-project?rev=80748&view=rev
Log:
Fix a little crasher in friend decls.  Thanks again to Eli for finding this.


Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=80748&r1=80747&r2=80748&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Sep  1 20:07:03 2009
@@ -715,10 +715,11 @@
   /// 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;

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp?rev=80748&r1=80747&r2=80748&view=diff

==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp Tue Sep  1 20:07:03 2009
@@ -29,6 +29,10 @@
   }
 };
 
+class A {
+  template <typename T> friend bool iszero(const A &a) throw();
+};
+
 int calc1() {
   Num<int> left = -1;
   Num<int> right = 1;





More information about the cfe-commits mailing list