diff options
author | Paul Chaignon <paul.chaignon@orange.com> | 2019-10-25 14:20:33 +0200 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2019-10-25 18:16:59 +0200 |
commit | ced0f73a673b1ab94725fe1710dcf7105015eb74 (patch) | |
tree | 12db31d48efb2df5b5b9cc1344eaf4149f2513e7 | |
parent | 9113054e42b65b811f594e4780f6ff4e1e363189 (diff) | |
download | syzkaller-ced0f73a673b1ab94725fe1710dcf7105015eb74.tar.gz |
pkg/compiler: check first int arg is range
Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
-rw-r--r-- | pkg/compiler/testdata/errors.txt | 2 | ||||
-rw-r--r-- | pkg/compiler/types.go | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt index bd7182252..a43cc55af 100644 --- a/pkg/compiler/testdata/errors.txt +++ b/pkg/compiler/testdata/errors.txt @@ -76,7 +76,7 @@ foo$11(a buffer["in"]) ### unexpected string "in" for direction argument of ptr foo$12(a buffer[10]) ### unexpected int 10 for direction argument of ptr type, expect [in out inout] foo$13(a int32[2:3]) foo$14(a int32[2:2]) -foo$16(a int32[3]) +foo$16(a int32[3]) ### first argument of int32 needs to be a range foo$17(a ptr[in, int32]) foo$18(a ptr[in, int32[2:3]]) foo$19(a ptr[in, int32[opt]]) diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go index 18027615d..928c15ba1 100644 --- a/pkg/compiler/types.go +++ b/pkg/compiler/types.go @@ -80,6 +80,9 @@ var typeInt = &typeDesc{ }, Check: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) { typeArgBase.Type.Check(comp, t) + if len(args) > 0 && len(args[0].Colon) == 0 { + comp.error(args[0].Pos, "first argument of %v needs to be a range", t.Ident) + } }, Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type { size, be := comp.parseIntType(t.Ident) |