[cfe-commits] r91678 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaTemplate/friend-template.cpp
John McCall
rjmccall at apple.com
Fri Dec 18 03:25:59 PST 2009
Author: rjmccall
Date: Fri Dec 18 05:25:59 2009
New Revision: 91678
URL: http://llvm.org/viewvc/llvm-project?rev=91678&view=rev
Log:
Set up the semantic context correctly when declaring a friend class template.
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/friend-template.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=91678&r1=91677&r2=91678&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Dec 18 05:25:59 2009
@@ -711,7 +711,7 @@
}
}
- if (PrevDecl && TUK == TUK_Friend) {
+ if (TUK == TUK_Friend) {
// C++ [namespace.memdef]p3:
// [...] When looking for a prior declaration of a class or a function
// declared as a friend, and when the name of the friend class or
@@ -720,9 +720,10 @@
DeclContext *OutermostContext = CurContext;
while (!OutermostContext->isFileContext())
OutermostContext = OutermostContext->getLookupParent();
-
- if (OutermostContext->Equals(PrevDecl->getDeclContext()) ||
- OutermostContext->Encloses(PrevDecl->getDeclContext())) {
+
+ if (PrevDecl &&
+ (OutermostContext->Equals(PrevDecl->getDeclContext()) ||
+ OutermostContext->Encloses(PrevDecl->getDeclContext()))) {
SemanticContext = PrevDecl->getDeclContext();
} else {
// Declarations in outer scopes don't matter. However, the outermost
Modified: cfe/trunk/test/SemaTemplate/friend-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/friend-template.cpp?rev=91678&r1=91677&r2=91678&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/friend-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/friend-template.cpp Fri Dec 18 05:25:59 2009
@@ -97,3 +97,13 @@
f(A<int>()); // expected-note {{in instantiation of function template specialization}}
}
}
+
+namespace test5 {
+ class outer {
+ class foo;
+ template <typename T> friend struct cache;
+ };
+ class outer::foo {
+ template <typename T> friend struct cache;
+ };
+}
More information about the cfe-commits
mailing list