Check return types of functions

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10146 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-11-21 22:32:23 +00:00
parent 1f254d50eb
commit c282f5a380
3 changed files with 9 additions and 0 deletions

View File

@ -1395,6 +1395,9 @@ FunctionHeaderH : TypesV Name '(' ArgList ')' {
UnEscapeLexed($2); UnEscapeLexed($2);
std::string FunctionName($2); std::string FunctionName($2);
if (!(*$1)->isFirstClassType() && *$1 != Type::VoidTy)
ThrowException("LLVM functions cannot return aggregate types!");
std::vector<const Type*> ParamTypeList; std::vector<const Type*> ParamTypeList;
if ($4) { // If there are arguments... if ($4) { // If there are arguments...
for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = $4->begin(); for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = $4->begin();

View File

@ -95,6 +95,9 @@ Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
ArgumentList.setParent(this); ArgumentList.setParent(this);
SymTab = new SymbolTable(); SymTab = new SymbolTable();
assert((getReturnType()->isFirstClassType() ||getReturnType() == Type::VoidTy)
&& "LLVM functions cannot return aggregate values!");
// Create the arguments vector, all arguments start out unnamed. // Create the arguments vector, all arguments start out unnamed.
for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) { for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) {
assert(Ty->getParamType(i) != Type::VoidTy && assert(Ty->getParamType(i) != Type::VoidTy &&

View File

@ -241,6 +241,9 @@ void Verifier::visitFunction(Function &F) {
Assert2(FT->getNumParams() == NumArgs, Assert2(FT->getNumParams() == NumArgs,
"# formal arguments must match # of arguments for function type!", "# formal arguments must match # of arguments for function type!",
&F, FT); &F, FT);
Assert1(F.getReturnType()->isFirstClassType() ||
F.getReturnType() == Type::VoidTy,
"Functions cannot return aggregate values!", &F);
// Check that the argument values match the function type for this function... // Check that the argument values match the function type for this function...
unsigned i = 0; unsigned i = 0;