diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-03-02 14:26:58 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-03-05 12:10:27 +0100 |
| commit | a339951e5f3c045290340330bcea3ff4155b8334 (patch) | |
| tree | e7ec9a7d5379d2ef2bef4c682ed7873f7e725dbb /pkg/compiler/testdata | |
| parent | 5110ff445ddb5a09a13e17b187c06d2dc3a7d52a (diff) | |
pkg/compiler: add size attribute for structs
The size attribute allows to pad a struct up to the specified size.
Diffstat (limited to 'pkg/compiler/testdata')
| -rw-r--r-- | pkg/compiler/testdata/all.txt | 11 | ||||
| -rw-r--r-- | pkg/compiler/testdata/consts.txt | 4 | ||||
| -rw-r--r-- | pkg/compiler/testdata/errors.txt | 16 | ||||
| -rw-r--r-- | pkg/compiler/testdata/errors2.txt | 13 |
4 files changed, 42 insertions, 2 deletions
diff --git a/pkg/compiler/testdata/all.txt b/pkg/compiler/testdata/all.txt index 442f08774..081bb1aab 100644 --- a/pkg/compiler/testdata/all.txt +++ b/pkg/compiler/testdata/all.txt @@ -183,6 +183,17 @@ foo$templ4(a ptr[in, templ_struct1[3]]) foo$templ5(a ptr[in, templ_struct1[3]]) foo$templ6(a ptr[in, templ_struct4]) + +# Structs. + +s0 { + f1 int8 +} [size[64]] + +s1 { + f1 int8 +} [size[C2]] + # Unions. u0 [ diff --git a/pkg/compiler/testdata/consts.txt b/pkg/compiler/testdata/consts.txt index b0bf8d4f1..f7c8daa35 100644 --- a/pkg/compiler/testdata/consts.txt +++ b/pkg/compiler/testdata/consts.txt @@ -31,3 +31,7 @@ type templ1[C] { f2 const[C, int8] } foo$1(a ptr[in, templ1[CONST20]]) + +str2 { + f1 int8 +} [size[CONST21]] diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt index 2b3a7539f..2d61d9e76 100644 --- a/pkg/compiler/testdata/errors.txt +++ b/pkg/compiler/testdata/errors.txt @@ -166,11 +166,23 @@ s8 { s9 { f1 int8 -} ["foo"[0]] ### bad struct/union attribute +} ["foo"[0]] ### unexpected string "foo", expect attribute s10 { f1 int8 -} [packed[0]] ### packed attribute had args +} [packed[0]] ### packed attribute has args + +s11 { + f1 int8 +} [size["foo"]] ### unexpected string "foo", expect int + +s12 { + f1 int8 +} [size[0:1]] ### size attribute has colon or args + +s13 { + f1 int8 +} [size[0[0]]] ### size attribute has colon or args u3 [ f1 int8 diff --git a/pkg/compiler/testdata/errors2.txt b/pkg/compiler/testdata/errors2.txt index f00a6afb4..a8d29789a 100644 --- a/pkg/compiler/testdata/errors2.txt +++ b/pkg/compiler/testdata/errors2.txt @@ -73,6 +73,19 @@ s2 { f1 s1 } +s3 { + f1 int8 +} [size[0]] ### size attribute has bad value 0, expect [1, 1<<20] + +s4 { + f1 int8 +} [size[1000000000]] ### size attribute has bad value 1000000000, expect [1, 1<<20] + +s6 { + f1 int8 + f2 array[int8] +} [size[10]] ### varlen struct s6 has size attribute + u1 [ f1 ptr[in, array[int8]] f2 len[f1, int32] ### len target f1 does not exist |
