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 | e9fc8dc84c4da2e9aea44c6e1a7bcc2af99d91c2 (patch) | |
| tree | d31e8804755d7370a528825b2ee538840866bec4 /clang/lib | |
| parent | 87c47499c6e2e5c3b6c0bac04ce9e6782bf6059c (diff) | |
| download | bcm5719-llvm-e9fc8dc84c4da2e9aea44c6e1a7bcc2af99d91c2.tar.gz bcm5719-llvm-e9fc8dc84c4da2e9aea44c6e1a7bcc2af99d91c2.zip | |
When searching for the instantiation of a locally-scoped tag
declaration, also look for an instantiation of its previous
declarations. Fixes PR8801.
llvm-svn: 122361
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 37d8d8cb53d..2fa4ac5b0b2 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/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; |

