diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-12-21 21:22:51 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-12-21 21:22:51 +0000 |
commit | ebb1c56a4b7a944921b564025df53505ff886050 (patch) | |
tree | c447b91c2617d6a15feb3ec9f58338599df9caa0 /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | b68e39930d06ed81a2b431dc09e4cb97e5c0d57a (diff) |
When searching for the instantiation of a locally-scoped tag
declaration, also look for an instantiation of its previous
declarations. Fixes PR8801.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122361 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 37d8d8cb53..2fa4ac5b0b 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -1735,11 +1735,21 @@ Decl *LocalInstantiationScope::getInstantiationOf(const Decl *D) { for (LocalInstantiationScope *Current = this; Current; Current = Current->Outer) { // Check if we found something within this scope. - llvm::DenseMap<const Decl *, Decl *>::iterator Found - = Current->LocalDecls.find(D); - if (Found != Current->LocalDecls.end()) - return Found->second; - + const Decl *CheckD = D; + do { + llvm::DenseMap<const Decl *, Decl *>::iterator Found + = Current->LocalDecls.find(CheckD); + if (Found != Current->LocalDecls.end()) + return Found->second; + + // If this is a tag declaration, it's possible that we need to look for + // a previous declaration. + if (const TagDecl *Tag = dyn_cast<TagDecl>(CheckD)) + CheckD = Tag->getPreviousDeclaration(); + else + CheckD = 0; + } while (CheckD); + // If we aren't combined with our outer scope, we're done. if (!Current->CombineWithOuterScope) break; |