diff options
author | John McCall <rjmccall@apple.com> | 2009-12-18 11:25:59 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-12-18 11:25:59 +0000 |
commit | 65c49466278f3739ac879f961b94b2aff744beed (patch) | |
tree | 340d999d55f5acef6686301a315ca68b4c302993 /lib/Sema/SemaTemplate.cpp | |
parent | 4e0d81f7088276ecf0c76824a28a9469482b067b (diff) |
Set up the semantic context correctly when declaring a friend class template.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91678 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index c1d828fe45..9b046e3696 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -711,7 +711,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, } } - 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 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, 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 |