cgo: better error message when using an undefined CGo function pointer

Этот коммит содержится в:
Ayke van Laethem 2019-04-20 02:42:13 +02:00 коммит произвёл Ron Evans
родитель 21a4c14e86
коммит 09db7ead50

Просмотреть файл

@ -2576,6 +2576,9 @@ func (c *Compiler) parseUnOp(frame *Frame, unop *ssa.UnOp) (llvm.Value, error) {
global := c.ir.GetGlobal(unop.X.(*ssa.Global))
name := global.LinkName()[:len(global.LinkName())-len("$funcaddr")]
fn := c.mod.NamedFunction(name)
if fn.IsNil() {
return llvm.Value{}, c.makeError(unop.Pos(), "cgo function not found: "+name)
}
return c.builder.CreateBitCast(fn, c.i8ptrType, ""), nil
} else {
c.emitNilCheck(frame, x, "deref")