mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: fix default alignment for empty structs
Fixes #5242. LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/125120043
This commit is contained in:
parent
03e6a88ef0
commit
31a996edb6
3 changed files with 35 additions and 0 deletions
|
|
@ -1534,6 +1534,9 @@ func (c *typeConv) pad(fld []*ast.Field, size int64) []*ast.Field {
|
|||
|
||||
// Struct conversion: return Go and (6g) C syntax for type.
|
||||
func (c *typeConv) Struct(dt *dwarf.StructType, pos token.Pos) (expr *ast.StructType, csyntax string, align int64) {
|
||||
// Minimum alignment for a struct is 1 byte.
|
||||
align = 1
|
||||
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString("struct {")
|
||||
fld := make([]*ast.Field, 0, 2*len(dt.Field)+1) // enough for padding around every field
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue