diff options
author | Rahat Mahmood <rahat@google.com> | 2020-04-01 16:50:16 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-04-01 16:51:28 -0700 |
commit | 1561ae3037e5a3efdd26320f229fc4c602258dba (patch) | |
tree | 23749691318ccd454c6799bc8bd5fe1ff7a8edcb /tools/go_marshal/test | |
parent | aecd3a25a99bc04fe2c032ea3422f10b2dba3256 (diff) |
go-marshal: Allow array lens to be consts and simple expressions.
Previously, go-marshal only allowed literals for array
lengths. However, it's very common for ABI structs to have a fix-sized
array whose length is defined by a constant; for example PATH_MAX.
Having to convert all such arrays to have literal lengths is too
awkward.
PiperOrigin-RevId: 304289345
Diffstat (limited to 'tools/go_marshal/test')
-rw-r--r-- | tools/go_marshal/test/test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/go_marshal/test/test.go b/tools/go_marshal/test/test.go index 43df73545..f75ca1b7f 100644 --- a/tools/go_marshal/test/test.go +++ b/tools/go_marshal/test/test.go @@ -146,3 +146,31 @@ type SignalSet uint64 // // +marshal slice:SignalSetAliasSlice type SignalSetAlias SignalSet + +const sizeA = 64 +const sizeB = 8 + +// TestArray is a test data structure on an array with a constant length. +// +// +marshal +type TestArray [sizeA]int32 + +// TestArray2 is a newtype on an array with a simple arithmetic expression of +// constants for the array length. +// +// +marshal +type TestArray2 [sizeA * sizeB]int32 + +// TestArray2 is a newtype on an array with a simple arithmetic expression of +// mixed constants and literals for the array length. +// +// +marshal +type TestArray3 [sizeA*sizeB + 12]int32 + +// Type9 is a test data type containing an array with a non-literal length. +// +// +marshal +type Type9 struct { + x int64 + y [sizeA]int32 +} |