mirror of
https://github.com/golang/go
synced 2024-11-14 15:00:27 -07:00
7388956b76
Consider this test package: package p // enum E { E0 }; // union U { long x; }; // void f(enum E e, union U* up) {} import "C" func f() { C.f(C.enum_E(C.E0), (*C.union_U)(nil)) } In Go 1.14, cgo translated this to (omitting irrelevant details): type _Ctype_union_U [8]byte func f() { _Cfunc_f(uint32(_Ciconst_E0), (*[8]byte)(nil)) } func _Cfunc_f(p0 uint32, p1 *[8]byte) (r1 _Ctype_void) { ... } Notably, _Ctype_union_U was declared as a defined type, but uses were being rewritten into uses of the underlying type, which matched how _Cfunc_f was declared. After CL 230037, cgo started consistently rewriting "C.foo" type expressions as "_Ctype_foo", which caused it to start emitting: type _Ctype_enum_E uint32 type _Ctype_union_U [8]byte func f() { _Cfunc_f(_Ctype_enum_E(_Ciconst_E0), (*_Ctype_union_U)(nil)) } // _Cfunc_f unchanged Of course, this fails to type-check because _Ctype_enum_E and _Ctype_union_U are defined types. This CL changes cgo to emit: type _Ctype_enum_E = uint32 type _Ctype_union_U = [8]byte // f unchanged since CL 230037 // _Cfunc_f still unchanged It would probably be better to fix this in (*typeConv).loadType so that cgo generated code uses the _Ctype_foo aliases too. But as it wouldn't have any effect on actual compilation, it's not worth the risk of touching it at this point in the release cycle. Updates #39537. Fixes #40494. Change-Id: I88269660b40aeda80a9a9433777601a781b48ac0 Reviewed-on: https://go-review.googlesource.com/c/go/+/246057 Reviewed-by: Ian Lance Taylor <iant@golang.org> |
||
---|---|---|
.. | ||
testdata | ||
backdoor.go | ||
buildid_linux.go | ||
callback_c_gc.c | ||
callback_c_gccgo.c | ||
callback_c.c | ||
callback.go | ||
cgo_linux_test.go | ||
cgo_stubs_android_test.go | ||
cgo_test.go | ||
cgo_thread_lock.go | ||
cgo_unix_test.go | ||
cthread_unix.c | ||
cthread_windows.c | ||
issue4029.c | ||
issue4029.go | ||
issue4029w.go | ||
issue4273.c | ||
issue4273b.c | ||
issue4339.c | ||
issue4339.h | ||
issue5548_c.c | ||
issue5740a.c | ||
issue5740b.c | ||
issue6833_c.c | ||
issue6907export_c.c | ||
issue6997_linux.c | ||
issue6997_linux.go | ||
issue7234_test.go | ||
issue8148.go | ||
issue8331.h | ||
issue8517_windows.c | ||
issue8517_windows.go | ||
issue8517.go | ||
issue8694.go | ||
issue8811.c | ||
issue18146.go | ||
issue20910.c | ||
issue21897.go | ||
issue21897b.go | ||
issue31891.c | ||
overlaydir_test.go | ||
pkg_test.go | ||
setgid_linux.go | ||
sigaltstack.go | ||
sigprocmask.c | ||
sigprocmask.go | ||
test_unix.go | ||
test_windows.go | ||
test.go | ||
testx.go |