diff options
| author | Serge Pavlov <sepavloff@gmail.com> | 2015-05-04 16:44:39 +0000 |
|---|---|---|
| committer | Serge Pavlov <sepavloff@gmail.com> | 2015-05-04 16:44:39 +0000 |
| commit | 4c51174677306561eb4a18bb05b20cd3030d4b74 (patch) | |
| tree | dd955ff4af5faaaa840146c140538496552abf30 /clang/lib | |
| parent | 19f731f0eaeb02eca8fc7b23a2435f021d7b7e9c (diff) | |
| download | bcm5719-llvm-4c51174677306561eb4a18bb05b20cd3030d4b74.tar.gz bcm5719-llvm-4c51174677306561eb4a18bb05b20cd3030d4b74.zip | |
Instantiate incomplete class used in template method.
If a class is absent from instantiation and is incomplete, instantiate it as
an incomplete class thus avoiding compiler crash.
This change fixes PR18653.
Differential Revision: http://reviews.llvm.org/D8281
llvm-svn: 236426
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 62b506276e6..18747825537 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2788,6 +2788,11 @@ LocalInstantiationScope::findInstantiationOf(const Decl *D) { isa<TemplateTemplateParmDecl>(D)) return nullptr; + // Tag type may be referenced prior to definition, in this case it does not + // have instantiation yet. + if (isa<TagDecl>(D)) + return nullptr; + // If we didn't find the decl, then we either have a sema bug, or we have a // forward reference to a label declaration. Return null to indicate that // we have an uninstantiated label. diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 8f2e95a6152..41245d9b3fd 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4434,6 +4434,14 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, if (D->isInvalidDecl()) return nullptr; + // Tag type may be referenced prior to definition, in this case it must be + // instantiated now. + if (const TagDecl *TD = dyn_cast<TagDecl>(D)) { + Decl *Inst = SubstDecl(D, CurContext, TemplateArgs); + CurrentInstantiationScope->InstantiatedLocal(D, Inst); + return cast<TypeDecl>(Inst); + } + // If we didn't find the decl, then we must have a label decl that hasn't // been found yet. Lazily instantiate it and return it now. assert(isa<LabelDecl>(D)); |

