Replace assertion with errormessage for unsupported calling conventions. like Pascal. See dstress/run/e/extern_10_A.d

This commit is contained in:
Tomas Lindquist Olsen
2009-02-04 00:04:09 +01:00
parent 280be5ef8e
commit bd4f7ec731
4 changed files with 14 additions and 11 deletions

View File

@@ -528,7 +528,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
// calling convention
if (!vafunc && fdecl->llvmInternal != LLVMintrinsic)
func->setCallingConv(DtoCallingConv(f->linkage));
func->setCallingConv(DtoCallingConv(fdecl->loc, f->linkage));
else // fall back to C, it should be the right thing to do
func->setCallingConv(llvm::CallingConv::C);

View File

@@ -113,7 +113,7 @@ void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, s
////////////////////////////////////////////
/// convert DMD calling conv to LLVM
unsigned DtoCallingConv(LINK l);
unsigned DtoCallingConv(Loc loc, LINK l);
///
TypeFunction* DtoTypeFunction(DValue* fnval);

View File

@@ -33,7 +33,7 @@ TypeFunction* DtoTypeFunction(DValue* fnval)
//////////////////////////////////////////////////////////////////////////////////////////
unsigned DtoCallingConv(LINK l)
unsigned DtoCallingConv(Loc loc, LINK l)
{
if (l == LINKc || l == LINKcpp || l == LINKintrinsic)
return llvm::CallingConv::C;
@@ -50,7 +50,10 @@ unsigned DtoCallingConv(LINK l)
else if (l == LINKwindows)
return llvm::CallingConv::X86_StdCall;
else
assert(0 && "Unsupported calling convention");
{
error(loc, "unsupported calling convention");
fatal();
}
}
//////////////////////////////////////////////////////////////////////////////////////////
@@ -235,7 +238,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
bool nestedcall = tf->usesNest;
bool dvarargs = (tf->linkage == LINKd && tf->varargs == 1);
unsigned callconv = DtoCallingConv(tf->linkage);
unsigned callconv = DtoCallingConv(loc, tf->linkage);
// get callee llvm value
LLValue* callable = DtoCallableValue(fnval);

View File

@@ -417,7 +417,7 @@ llvm::Function* build_module_ctor()
const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::VoidTy,argsTy,false);
assert(gIR->module->getFunction(name) == NULL);
llvm::Function* fn = llvm::Function::Create(fnTy, llvm::GlobalValue::InternalLinkage, name, gIR->module);
fn->setCallingConv(DtoCallingConv(LINKd));
fn->setCallingConv(DtoCallingConv(0, LINKd));
llvm::BasicBlock* bb = llvm::BasicBlock::Create("entry", fn);
IRBuilder<> builder(bb);
@@ -432,7 +432,7 @@ llvm::Function* build_module_ctor()
for (size_t i=0; i<n; i++) {
llvm::Function* f = gIR->ctors[i]->ir.irFunc->func;
llvm::CallInst* call = builder.CreateCall(f,"");
call->setCallingConv(DtoCallingConv(LINKd));
call->setCallingConv(DtoCallingConv(0, LINKd));
}
// debug info end
@@ -462,7 +462,7 @@ static llvm::Function* build_module_dtor()
const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::VoidTy,argsTy,false);
assert(gIR->module->getFunction(name) == NULL);
llvm::Function* fn = llvm::Function::Create(fnTy, llvm::GlobalValue::InternalLinkage, name, gIR->module);
fn->setCallingConv(DtoCallingConv(LINKd));
fn->setCallingConv(DtoCallingConv(0, LINKd));
llvm::BasicBlock* bb = llvm::BasicBlock::Create("entry", fn);
IRBuilder<> builder(bb);
@@ -477,7 +477,7 @@ static llvm::Function* build_module_dtor()
for (size_t i=0; i<n; i++) {
llvm::Function* f = gIR->dtors[i]->ir.irFunc->func;
llvm::CallInst* call = builder.CreateCall(f,"");
call->setCallingConv(DtoCallingConv(LINKd));
call->setCallingConv(DtoCallingConv(0, LINKd));
}
// debug info end
@@ -507,7 +507,7 @@ static llvm::Function* build_module_unittest()
const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::VoidTy,argsTy,false);
assert(gIR->module->getFunction(name) == NULL);
llvm::Function* fn = llvm::Function::Create(fnTy, llvm::GlobalValue::InternalLinkage, name, gIR->module);
fn->setCallingConv(DtoCallingConv(LINKd));
fn->setCallingConv(DtoCallingConv(0, LINKd));
llvm::BasicBlock* bb = llvm::BasicBlock::Create("entry", fn);
IRBuilder<> builder(bb);
@@ -522,7 +522,7 @@ static llvm::Function* build_module_unittest()
for (size_t i=0; i<n; i++) {
llvm::Function* f = gIR->unitTests[i]->ir.irFunc->func;
llvm::CallInst* call = builder.CreateCall(f,"");
call->setCallingConv(DtoCallingConv(LINKd));
call->setCallingConv(DtoCallingConv(0, LINKd));
}
// debug info end