]> Cypherpunks repositories - gostls13.git/commit
cmd/cgo: fix handling of array of pointers when using clang
authorRuss Cox <rsc@golang.org>
Thu, 7 Nov 2013 20:24:51 +0000 (15:24 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 7 Nov 2013 20:24:51 +0000 (15:24 -0500)
commit6be1cb8c7a8771310e0cc36c3d8fa783d48d0cf9
treeeedb8c6d798b4e13b9f67b60b7b0e590824ce893
parent8d206d9d804d793727a668a21711dac69689cf23
cmd/cgo: fix handling of array of pointers when using clang

Clang does not record the "size" field for pointer types,
so we must insert the size ourselves. We were already
doing this, but only for the case of pointer types.
For an array of pointer types, the setting of the size for
the nested pointer type was happening after the computation
of the size of the array type, meaning that the array type
was always computed as 0 bytes. Delay the size computation.

This bug happens on all Clang systems, not just FreeBSD.
Our test checked that cgo wrote something, not that it was correct.
FreeBSD's default clang rejects array[0] as a C struct field,
so it noticed the incorrect sizes. But the sizes were incorrect
everywhere.

Update testcdefs to check the output has the right semantics.

Fixes #6292.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/22840043
misc/cgo/testcdefs/main.c [new file with mode: 0644]
misc/cgo/testcdefs/main.go
misc/cgo/testcdefs/test.bash
src/cmd/cgo/gcc.go