diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-01-10 16:13:34 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-01-13 12:52:09 +0100 |
| commit | 6b52293f4defa6b45b564d037fd641be5d6d0e0e (patch) | |
| tree | 53c7f28df3fd2666ca165ce7231d470c9d1e2dc5 /pkg/compiler/testdata/errors2.txt | |
| parent | 9dc808a65eb3f44d64e078b79bcac0f0510629f6 (diff) | |
pkg/compiler: support type templates
Netlink descriptions contain tons of code duplication,
and need much more for proper descriptions. Introduce
type templates to simplify writing such descriptions
and remove code duplication.
Note: type templates are experimental, have poor error handling
and are subject to change.
Type templates can be declared as follows:
```
type buffer[DIR] ptr[DIR, array[int8]]
type fileoff[BASE] BASE
type nlattr[TYPE, PAYLOAD] {
nla_len len[parent, int16]
nla_type const[TYPE, int16]
payload PAYLOAD
} [align_4]
```
and later used as follows:
```
syscall(a buffer[in], b fileoff[int64], c ptr[in, nlattr[FOO, int32]])
```
Diffstat (limited to 'pkg/compiler/testdata/errors2.txt')
| -rw-r--r-- | pkg/compiler/testdata/errors2.txt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/compiler/testdata/errors2.txt b/pkg/compiler/testdata/errors2.txt index 5b418ab55..67127c6ad 100644 --- a/pkg/compiler/testdata/errors2.txt +++ b/pkg/compiler/testdata/errors2.txt @@ -42,6 +42,18 @@ sr7 { f1 ptr[in, sr7, opt] } +type templ_sr[T] { + f T +} + +sr8 { + f templ_sr[sr8] ### recursive declaration: sr8.f -> templ_sr[sr8].f -> sr8 (mark some pointers as opt) +} + +sr9 { + f templ_sr[ptr[in, sr9]] ### recursive declaration: sr9.f -> templ_sr[ptr[in, sr9]].f -> sr9 (mark some pointers as opt) +} + # Len target tests. foo$100(a int32, b len[a]) @@ -134,3 +146,17 @@ s403 { sf400 = "foo", "bar", "baz" sf401 = "a", "b", "cd" + +# Const argument checks. + +foo$500(a int32[3:2]) ### bad int range [3:2] +foo$501(a ptr[in, int32[3:2]]) ### bad int range [3:2] +foo$502(a ptr[in, string["foo", C1]]) ### string value "foo\x00" exceeds buffer length 1 +foo$503(a ptr[in, proc[1000, 1, int8]]) ### values starting from 1000 overflow base type +foo$504(a ptr[in, proc[20, 10, int8]]) ### values starting from 20 with step 10 overflow base type for 32 procs +foo$505(a proc[20, 0]) ### proc per-process values must not be 0 +foo$506(a ptr[in, array[int32, 0]]) ### arrays of size 0 are not supported +foo$507(a ptr[in, array[int32, 0:0]]) ### arrays of size 0 are not supported +foo$508(a ptr[in, string["foo", 3]]) ### string value "foo\x00" exceeds buffer length 3 + +type type500 proc[C1, 8, int8] ### values starting from 1 with step 8 overflow base type for 32 procs |
