diff options
author | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2011-05-27 20:00:14 +0000 |
---|---|---|
committer | Sean Hunt <scshunt@csclub.uwaterloo.ca> | 2011-05-27 20:00:14 +0000 |
commit | f996e051d9953550982b57132daad8a5e3f7bd65 (patch) | |
tree | 04b8e2628a51789189eccb53752f253d7065006f /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | e413516d0ed61ef9e2ff706bcc00480adca947c4 (diff) |
Add assertions to verify that we are not trying to instantiate a
nontemplate in Sema::InstantiateTemplateDecl.
This should make the issue in PR10026 more visible, although it's not
going to fix it because something is violating this precondition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132208 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index e9c09c39f3..bf1e4996ec 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2317,16 +2317,18 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, // Find the function body that we'll be substituting. const FunctionDecl *PatternDecl = Function->getTemplateInstantiationPattern(); - Stmt *Pattern = 0; - if (PatternDecl) { - Pattern = PatternDecl->getBody(PatternDecl); - if (!Pattern) - // Try to find a defaulted definition - PatternDecl->isDefined(PatternDecl); + assert(PatternDecl && "instantiating a non-template"); + + Stmt *Pattern = PatternDecl->getBody(PatternDecl); + assert(PatternDecl && "template definition is not a template"); + if (!Pattern) { + // Try to find a defaulted definition + PatternDecl->isDefined(PatternDecl); } + assert(PatternDecl && "template definition is not a template"); // Postpone late parsed template instantiations. - if (PatternDecl && PatternDecl->isLateTemplateParsed() && + if (PatternDecl->isLateTemplateParsed() && !LateTemplateParser) { PendingInstantiations.push_back( std::make_pair(Function, PointOfInstantiation)); @@ -2335,13 +2337,13 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, // Call the LateTemplateParser callback if there a need to late parse // a templated function definition. - if (!Pattern && PatternDecl && PatternDecl->isLateTemplateParsed() && + if (!Pattern && PatternDecl->isLateTemplateParsed() && LateTemplateParser) { LateTemplateParser(OpaqueParser, PatternDecl); Pattern = PatternDecl->getBody(PatternDecl); } - if (!Pattern && PatternDecl && !PatternDecl->isDefaulted()) { + if (!Pattern && !PatternDecl->isDefaulted()) { if (DefinitionRequired) { if (Function->getPrimaryTemplate()) Diag(PointOfInstantiation, |