diff options
author | John McCall <rjmccall@apple.com> | 2011-04-27 06:46:31 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-04-27 06:46:31 +0000 |
commit | d46a1125d43bcfd47fbd1206ebd1226863549390 (patch) | |
tree | 3a0b67f73ebd43b3b2a0e281d6c278016d236ace /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 5ecdd78408a1c6f4be506d94f776642570d27336 (diff) |
Diagnose attempts to implicitly instantiate a template before it is
fully defined. Somehow this escaped notice for a very long time.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130298 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index c951b2573a..749c4a18a4 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -1650,9 +1650,18 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *PatternDef = cast_or_null<CXXRecordDecl>(Pattern->getDefinition()); - if (!PatternDef) { - if (!Complain) { + if (!PatternDef || PatternDef->isBeingDefined()) { + if (!Complain || (PatternDef && PatternDef->isInvalidDecl())) { // Say nothing + } else if (PatternDef) { + assert(PatternDef->isBeingDefined()); + Diag(PointOfInstantiation, + diag::err_template_instantiate_within_definition) + << (TSK != TSK_ImplicitInstantiation) + << Context.getTypeDeclType(Instantiation); + // Not much point in noting the template declaration here, since + // we're lexically inside it. + Instantiation->setInvalidDecl(); } else if (Pattern == Instantiation->getInstantiatedFromMemberClass()) { Diag(PointOfInstantiation, diag::err_implicit_instantiate_member_undefined) |