mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 18:53:29 +00:00
cgo: better error message when using an undefined CGo function pointer
This commit is contained in:
committed by
Ron Evans
parent
21a4c14e86
commit
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))
|
global := c.ir.GetGlobal(unop.X.(*ssa.Global))
|
||||||
name := global.LinkName()[:len(global.LinkName())-len("$funcaddr")]
|
name := global.LinkName()[:len(global.LinkName())-len("$funcaddr")]
|
||||||
fn := c.mod.NamedFunction(name)
|
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
|
return c.builder.CreateBitCast(fn, c.i8ptrType, ""), nil
|
||||||
} else {
|
} else {
|
||||||
c.emitNilCheck(frame, x, "deref")
|
c.emitNilCheck(frame, x, "deref")
|
||||||
|
|||||||
Reference in New Issue
Block a user