]> Cypherpunks repositories - gostls13.git/commit
cmd/cgo, debug/dwarf: fix translation of zero-size arrays
authorMatthew Dempsky <mdempsky@google.com>
Wed, 13 Aug 2014 18:16:30 +0000 (11:16 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 13 Aug 2014 18:16:30 +0000 (11:16 -0700)
commit078a9cbc6cf539074ae975debc5d5396352d16b7
treec20af6c21001b185354a01ff071b1a83ca07e6fd
parent187d0f672029e0fa0106024dd2f554b247aa7aff
cmd/cgo, debug/dwarf: fix translation of zero-size arrays

In cgo, now that recursive calls to typeConv.Type() always work,
we can more robustly calculate the array sizes based on the size
of our element type.

Also, in debug/dwarf, the decision to call zeroType is made
based on a type's usage within a particular struct, but dwarf.Type
values are cached in typeCache, so the modification might affect
uses of the type in other structs.  Current compilers don't appear
to share DWARF type entries for "[]foo" and "[0]foo", but they also
don't consistently share type entries in other cases.  Arguably
modifying the types is an improvement in some cases, but varying
translated types according to compiler whims seems like a bad idea.

Lastly, also in debug/dwarf, zeroType only needs to rewrite the
top-level dimension, and only if the rest of the array size is
non-zero.

Fixes #8428.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/127980043
misc/cgo/test/issue8428.go [new file with mode: 0644]
src/cmd/cgo/gcc.go
src/pkg/debug/dwarf/type.go