From 46a9df47e4035c842acf36feac24ced207dd0004 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sat, 27 Apr 2024 08:33:49 +0800 Subject: [PATCH] cl: _testcgo/typalias --- cl/_testcgo/typalias/in.go | 25 +++++++++++++++++++++++++ cl/_testcgo/typalias/out.ll | 0 cl/compile_test.go | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 cl/_testcgo/typalias/in.go create mode 100644 cl/_testcgo/typalias/out.ll diff --git a/cl/_testcgo/typalias/in.go b/cl/_testcgo/typalias/in.go new file mode 100644 index 00000000..273651f6 --- /dev/null +++ b/cl/_testcgo/typalias/in.go @@ -0,0 +1,25 @@ +package main + +import "C" +import _ "unsafe" + +//go:linkname printf C.printf +func printf(format *int8, __llgo_va_list ...any) + +type Foo = struct { + A C.int + ok bool +} + +var format = [...]int8{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0} + +func Print(p *Foo) { + if p.ok { + printf(&format[0], p.A) + } +} + +func main() { + foo := &Foo{100, true} + Print(foo) +} diff --git a/cl/_testcgo/typalias/out.ll b/cl/_testcgo/typalias/out.ll new file mode 100644 index 00000000..e69de29b diff --git a/cl/compile_test.go b/cl/compile_test.go index 671f8cba..036618a9 100644 --- a/cl/compile_test.go +++ b/cl/compile_test.go @@ -28,7 +28,7 @@ func testCompile(t *testing.T, src, expected string) { } func TestFromTestcgo(t *testing.T) { - cltest.FromDir(t, "", "./_testcgo", true) + cltest.FromDir(t, "typalias", "./_testcgo", true) } func TestFromTestdata(t *testing.T) {