From: Anton Korobeynikov Date: Mon, 3 Dec 2007 21:00:45 +0000 (+0000) Subject: Fix fallout from my last patch: don't reject varargs functions :) X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=f8c751a663f8ce2461a189f9c78eae7b73b65911;p=oota-llvm.git Fix fallout from my last patch: don't reject varargs functions :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44545 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index ae6da07893f..16204ccf9b9 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -1331,22 +1331,26 @@ Types // Allow but ignore attributes on function types; this permits auto-upgrade. // FIXME: remove in LLVM 3.0. const Type* RetTy = *$1; - if (!(RetTy->isFirstClassType() || isa(RetTy))) + if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy || + isa(RetTy))) GEN_ERROR("LLVM Functions cannot return aggregates"); std::vector Params; TypeWithAttrsList::iterator I = $3->begin(), E = $3->end(); for (; I != E; ++I ) { const Type *Ty = I->Ty->get(); - if (!(Ty->isFirstClassType() || isa(Ty))) - GEN_ERROR("Function arguments must be value types!"); Params.push_back(Ty); } - CHECK_FOR_ERROR bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); + for (unsigned i = 0; i != Params.size(); ++i) + if (!(Params[i]->isFirstClassType() || isa(Params[i]))) + GEN_ERROR("Function arguments must be value types!"); + + CHECK_FOR_ERROR + FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg); delete $3; // Delete the argument list delete $1; // Delete the return type handle @@ -1360,15 +1364,18 @@ Types TypeWithAttrsList::iterator I = $3->begin(), E = $3->end(); for ( ; I != E; ++I ) { const Type* Ty = I->Ty->get(); - if (!(Ty->isFirstClassType() || isa(Ty))) - GEN_ERROR("Function arguments must be value types!"); Params.push_back(Ty); } - CHECK_FOR_ERROR bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); + for (unsigned i = 0; i != Params.size(); ++i) + if (!(Params[i]->isFirstClassType() || isa(Params[i]))) + GEN_ERROR("Function arguments must be value types!"); + + CHECK_FOR_ERROR + FunctionType *FT = FunctionType::get($1, Params, isVarArg); delete $3; // Delete the argument list $$ = new PATypeHolder(HandleUpRefs(FT));