Generate a parse error instead of a checked exception if template args are

used on a def.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23545 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-09-30 04:42:31 +00:00
parent ef242b1ccc
commit 583a0249b6

View File

@ -559,14 +559,14 @@ DefName : ObjectName {
Records.addDef(CurRec); Records.addDef(CurRec);
}; };
ObjectBody : OptTemplateArgList ClassList { ObjectBody : ClassList {
ParsingTemplateArgs = false; ParsingTemplateArgs = false;
for (unsigned i = 0, e = $2->size(); i != e; ++i) { for (unsigned i = 0, e = $1->size(); i != e; ++i) {
addSubClass((*$2)[i].first, *(*$2)[i].second); addSubClass((*$1)[i].first, *(*$1)[i].second);
// Delete the template arg values for the class // Delete the template arg values for the class
delete (*$2)[i].second; delete (*$1)[i].second;
} }
delete $2; // Delete the class list... delete $1; // Delete the class list...
// Process any variables on the set stack... // Process any variables on the set stack...
for (unsigned i = 0, e = LetStack.size(); i != e; ++i) for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
@ -579,19 +579,15 @@ ObjectBody : OptTemplateArgList ClassList {
CurRec = 0; CurRec = 0;
}; };
ClassInst : CLASS ClassName ObjectBody { ClassInst : CLASS ClassName OptTemplateArgList ObjectBody {
$$ = $3; $$ = $4;
}; };
DefInst : DEF DefName ObjectBody { DefInst : DEF DefName ObjectBody {
$3->resolveReferences(); $3->resolveReferences();
// If ObjectBody has template arguments, it's an error. // If ObjectBody has template arguments, it's an error.
if (!$3->getTemplateArgs().empty()) { assert($3->getTemplateArgs().empty() && "How'd this get template args?");
err() << "Def '" << $3->getName()
<< "' is not permitted to have template arguments!\n";
exit(1);
}
$$ = $3; $$ = $3;
}; };