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.

llvm-svn: 132208
This commit is contained in:
Alexis Hunt 2011-05-27 20:00:14 +00:00
parent 3252177f16
commit 23f6b83d6f
1 changed files with 11 additions and 9 deletions

View File

@ -2317,16 +2317,18 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
// Find the function body that we'll be substituting. // Find the function body that we'll be substituting.
const FunctionDecl *PatternDecl = Function->getTemplateInstantiationPattern(); const FunctionDecl *PatternDecl = Function->getTemplateInstantiationPattern();
Stmt *Pattern = 0; assert(PatternDecl && "instantiating a non-template");
if (PatternDecl) {
Pattern = PatternDecl->getBody(PatternDecl); Stmt *Pattern = PatternDecl->getBody(PatternDecl);
if (!Pattern) assert(PatternDecl && "template definition is not a template");
// Try to find a defaulted definition if (!Pattern) {
PatternDecl->isDefined(PatternDecl); // Try to find a defaulted definition
PatternDecl->isDefined(PatternDecl);
} }
assert(PatternDecl && "template definition is not a template");
// Postpone late parsed template instantiations. // Postpone late parsed template instantiations.
if (PatternDecl && PatternDecl->isLateTemplateParsed() && if (PatternDecl->isLateTemplateParsed() &&
!LateTemplateParser) { !LateTemplateParser) {
PendingInstantiations.push_back( PendingInstantiations.push_back(
std::make_pair(Function, PointOfInstantiation)); 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 // Call the LateTemplateParser callback if there a need to late parse
// a templated function definition. // a templated function definition.
if (!Pattern && PatternDecl && PatternDecl->isLateTemplateParsed() && if (!Pattern && PatternDecl->isLateTemplateParsed() &&
LateTemplateParser) { LateTemplateParser) {
LateTemplateParser(OpaqueParser, PatternDecl); LateTemplateParser(OpaqueParser, PatternDecl);
Pattern = PatternDecl->getBody(PatternDecl); Pattern = PatternDecl->getBody(PatternDecl);
} }
if (!Pattern && PatternDecl && !PatternDecl->isDefaulted()) { if (!Pattern && !PatternDecl->isDefaulted()) {
if (DefinitionRequired) { if (DefinitionRequired) {
if (Function->getPrimaryTemplate()) if (Function->getPrimaryTemplate())
Diag(PointOfInstantiation, Diag(PointOfInstantiation,