diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-09-04 19:52:55 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-09-04 20:25:22 +0200 |
| commit | 54a92e90e0cfa9637bb5c4db4ffb4392e22705d5 (patch) | |
| tree | 4482ab8f74c449b9afd9a97ab8c20b3604815fe4 /pkg/compiler | |
| parent | 740662e03a9abc235689531ec363c852f3f1b21c (diff) | |
pkg/compiler: prohibit bitfields in syscall args
Diffstat (limited to 'pkg/compiler')
| -rw-r--r-- | pkg/compiler/check.go | 2 | ||||
| -rw-r--r-- | pkg/compiler/testdata/errors.txt | 1 | ||||
| -rw-r--r-- | pkg/compiler/types.go | 2 |
3 files changed, 3 insertions, 2 deletions
diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go index 7510429d9..5a3dea450 100644 --- a/pkg/compiler/check.go +++ b/pkg/compiler/check.go @@ -404,7 +404,7 @@ func (comp *compiler) checkType(t *ast.Type, isArg, isRet, isResourceBase bool) comp.error(t.Pos, "unknown type %v", t.Ident) return } - if !desc.AllowColon && t.HasColon { + if t.HasColon && (!desc.AllowColon || isArg) { comp.error(t.Pos2, "unexpected ':'") return } diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt index 6be60ef91..dc535b000 100644 --- a/pkg/compiler/testdata/errors.txt +++ b/pkg/compiler/testdata/errors.txt @@ -108,6 +108,7 @@ foo$43(a ptr[in, string[1]]) ### unexpected int 1, string arg must be a string l foo$44(a int32) len[a] ### len can't be syscall return foo$45(a int32) len[b] ### len can't be syscall return foo$46(a ptr[in, in]) ### unknown type in +foo$47(a int32:2) ### unexpected ':' opt { ### struct uses reserved name opt f1 int32 diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go index 5db294fda..035a47165 100644 --- a/pkg/compiler/types.go +++ b/pkg/compiler/types.go @@ -18,7 +18,7 @@ type typeDesc struct { CantBeOpt bool // can't be marked as opt? CantBeRet bool // can't be syscall return (directly or indirectly)? NeedBase bool // needs base type when used as field? - AllowColon bool // allow colon (int8:2)? + AllowColon bool // allow colon (int8:2) on fields? ResourceBase bool // can be resource base type? OptArgs int // number of optional arguments in Args array Args []namedArg // type arguments |
