func TestThreadLock(t *testing.T) { testThreadLockFunc(t) }
func TestUnsignedInt(t *testing.T) { testUnsignedInt(t) }
func TestZeroArgCallback(t *testing.T) { testZeroArgCallback(t) }
+func Test76340(t *testing.T) { test76340(t) }
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
func BenchmarkGoString(b *testing.B) { benchGoString(b) }
#define issue75751m issue75751p
char * const volatile issue75751p2 = &issue75751v;
#define issue75751m2 issue75751p2
+
+typedef struct { void *t; void *v; } GoInterface;
+extern int exportAny76340Param(GoInterface);
+extern GoInterface exportAny76340Return(int);
+
+int issue76340testFromC(GoInterface obj) {
+ return exportAny76340Param(obj);
+}
+
+GoInterface issue76340returnFromC(int val) {
+ return exportAny76340Return(val);
+}
*/
import "C"
func test75751() int {
return int(*C.issue75751m) + int(*C.issue75751m2)
}
+
+// Issue 76340.
+func test76340(t *testing.T) {
+ var emptyInterface C.GoInterface
+ r1 := C.issue76340testFromC(emptyInterface)
+ if r1 != 0 {
+ t.Errorf("issue76340testFromC with nil interface: got %d, want 0", r1)
+ }
+
+ r2 := C.issue76340returnFromC(42)
+ if r2.t == nil && r2.v == nil {
+ t.Error("issue76340returnFromC(42) returned nil interface")
+ }
+
+ r3 := C.issue76340returnFromC(0)
+ if r3.t != nil || r3.v != nil {
+ t.Errorf("issue76340returnFromC(0) returned non-nil interface: got %v, want nil", r3)
+ }
+}
t.Errorf("msg = %q, want 'hello'", v.msg)
}
}
+
+//export exportAny76340Param
+func exportAny76340Param(obj any) C.int {
+ if obj == nil {
+ return 0
+ }
+
+ return 1
+}
+
+//export exportAny76340Return
+func exportAny76340Return(val C.int) any {
+ if val == 0 {
+ return nil
+ }
+
+ return int(val)
+}
if t.Name == "error" {
return &Type{Size: 2 * p.PtrSize, Align: p.PtrSize, C: c("GoInterface")}
}
+ if t.Name == "any" {
+ return &Type{Size: 2 * p.PtrSize, Align: p.PtrSize, C: c("GoInterface")}
+ }
if r, ok := goTypes[t.Name]; ok {
return goTypesFixup(r)
}