diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2022-01-05 20:05:11 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2022-01-11 16:30:08 +0100 |
| commit | 2cfe62f82077ba012aef55db5288985bc0c426d9 (patch) | |
| tree | 501d83deb358a230d157c9d7efc6fc393e239472 /prog/analysis.go | |
| parent | 16e21d13ea26a631e9b3a30c94635b1d565fd78f (diff) | |
pkg/compiler: add out_overlay field attribute
Diffstat (limited to 'prog/analysis.go')
| -rw-r--r-- | prog/analysis.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/prog/analysis.go b/prog/analysis.go index 697e1eab5..1b572f0c0 100644 --- a/prog/analysis.go +++ b/prog/analysis.go @@ -132,22 +132,29 @@ func foreachArgImpl(arg Arg, ctx *ArgCtx, f func(Arg, *ArgCtx)) { } switch a := arg.(type) { case *GroupArg: + overlayField := 0 if typ, ok := a.Type().(*StructType); ok { ctx.Parent = &a.Inner ctx.Fields = typ.Fields + overlayField = typ.OverlayField } var totalSize uint64 - for _, arg1 := range a.Inner { + for i, arg1 := range a.Inner { + if i == overlayField { + ctx.Offset = ctx0.Offset + } foreachArgImpl(arg1, ctx, f) size := arg1.Size() ctx.Offset += size - totalSize += size + if totalSize < ctx.Offset { + totalSize = ctx.Offset - ctx0.Offset + } } claimedSize := a.Size() varlen := a.Type().Varlen() if varlen && totalSize > claimedSize || !varlen && totalSize != claimedSize { panic(fmt.Sprintf("bad group arg size %v, should be <= %v for %#v type %#v", - totalSize, claimedSize, a, a.Type())) + totalSize, claimedSize, a, a.Type().Name())) } case *PointerArg: if a.Res != nil { |
