]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.10] cmd/cgo: check function argument/return types for bad C point...
authorKeith Randall <khr@golang.org>
Sat, 7 Jul 2018 04:38:31 +0000 (21:38 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 8 Aug 2018 00:26:43 +0000 (00:26 +0000)
commit48016b89d9ec26eb447b6bc78cabe48384ff4885
tree7a6f63ffd9d4772a524b2604ca7c36fc82bcedb5
parent815e0f9755e6e2a0db9c36db1af6550c1f750d8e
[release-branch.go1.10] cmd/cgo: check function argument/return types for bad C pointer types

We need to determine whether arguments to and return values from C
functions are "bad" typedef'd pointer types which need to be uintptr
on the Go side.

The type of those arguments are not specified explicitly. As a result,
we never look through the C declarations for the GetTypeID functions
associated with that type, and never realize that they are bad.
However, in another function in the same package there might be an
explicit reference. Then we end up with the declaration being uintptr
in one file and *struct{...} in another file. Badness ensues.

Fix this by doing a 2-pass algorithm. In the first pass, we run as
normal, but record all the argument and result types we see. In the
second pass, we include those argument types also when reading the C
types.

Update #25036

Change-Id: I8d727e73a2fbc88cb9d9899f8719ae405f59f753
Reviewed-on: https://go-review.googlesource.com/122575
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 20803e0f52809fa6088285c1c87246642df2b62d)
Reviewed-on: https://go-review.googlesource.com/122818
misc/cgo/test/issue24161_darwin_test.go [new file with mode: 0644]
misc/cgo/test/issue24161arg/def.go [new file with mode: 0644]
misc/cgo/test/issue24161arg/use.go [new file with mode: 0644]
misc/cgo/test/issue24161res/restype.go [new file with mode: 0644]
src/cmd/cgo/gcc.go
src/cmd/cgo/main.go