aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/Sema.h7
-rw-r--r--test/CXX/temp/temp.decls/temp.friend/p1.cpp4
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 63d2831fab..e2205d6df5 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -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;
diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
index 4f0037d470..4434d48389 100644
--- a/test/CXX/temp/temp.decls/temp.friend/p1.cpp
+++ b/test/CXX/temp/temp.decls/temp.friend/p1.cpp
@@ -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;