mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: fix register/offset calculation for trailing empty field case.
Includes test. Long term, need to make the offending code be more in terms of official types package offsets, instead of duplicating that logic. For #40724. Change-Id: Id33a153f10aed3289cc48d1f99a8e0f6ece9474d Reviewed-on: https://go-review.googlesource.com/c/go/+/306469 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
e6ac2df2b1
commit
45ca9ef5c1
2 changed files with 43 additions and 1 deletions
|
|
@ -211,8 +211,11 @@ func appendParamOffsets(offsets []int64, at int64, t *types.Type) ([]int64, int6
|
|||
offsets, at = appendParamOffsets(offsets, at, t.Elem())
|
||||
}
|
||||
case types.TSTRUCT:
|
||||
for _, f := range t.FieldSlice() {
|
||||
for i, f := range t.FieldSlice() {
|
||||
offsets, at = appendParamOffsets(offsets, at, f.Type)
|
||||
if f.Type.Width == 0 && i == t.NumFields()-1 {
|
||||
at++ // last field has zero width
|
||||
}
|
||||
}
|
||||
at = align(at, t) // type size is rounded up to its alignment
|
||||
case types.TSLICE:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue