summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorSerge Pavlov <sepavloff@gmail.com>2015-05-04 16:44:39 +0000
committerSerge Pavlov <sepavloff@gmail.com>2015-05-04 16:44:39 +0000
commit4c51174677306561eb4a18bb05b20cd3030d4b74 (patch)
treedd955ff4af5faaaa840146c140538496552abf30 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
parent19f731f0eaeb02eca8fc7b23a2435f021d7b7e9c (diff)
downloadbcm5719-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/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp8
1 files changed, 8 insertions, 0 deletions
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));
OpenPOWER on IntegriCloud