Skip to content

Commit

Permalink
Throw an error when call is not a function for the fallback case. Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Aug 13, 2015
1 parent f2bd731 commit 1eb5a73
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2688,17 +2688,24 @@ static Value *emit_call(jl_value_t **args, size_t arglen, jl_codectx_t *ctx, jl_
builder.SetInsertPoint(elseBB1);
// not function
myargs = emit_temp_slot(argStart, ctx);
jl_value_t *call_func = (jl_value_t*)jl_module_call_func(ctx->module);
Value *r2;
if (call_func == (jl_value_t*)jl_bottom_func) {
just_emit_error("\"call\" is not a function", ctx);
r2 = UndefValue::get(jl_pvalue_llvmt);
} else {
#ifdef LLVM37
Value *r2 = builder.CreateCall(prepare_call(jlapplygeneric_func),
{literal_pointer_val((jl_value_t*)jl_module_call_func(ctx->module)),
myargs,
ConstantInt::get(T_int32,nargs+1)});
r2 = builder.CreateCall(prepare_call(jlapplygeneric_func),
{literal_pointer_val(call_func),
myargs,
ConstantInt::get(T_int32, nargs + 1)});
#else
Value *r2 = builder.CreateCall3(prepare_call(jlapplygeneric_func),
literal_pointer_val((jl_value_t*)jl_module_call_func(ctx->module)),
myargs,
ConstantInt::get(T_int32,nargs+1));
r2 = builder.CreateCall3(prepare_call(jlapplygeneric_func),
literal_pointer_val(call_func),
myargs,
ConstantInt::get(T_int32, nargs + 1));
#endif
}
builder.CreateBr(mergeBB1);
ctx->f->getBasicBlockList().push_back(mergeBB1);
builder.SetInsertPoint(mergeBB1);
Expand Down

0 comments on commit 1eb5a73

Please sign in to comment.