diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-02-17 16:51:52 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-02-17 19:02:12 +0100 |
| commit | dd4fcef5a270fc39a56c0be8122fc6f18314f3cd (patch) | |
| tree | c7d1dccb26b31dec062b7d493060b624c8a84f0f /pkg/compiler | |
| parent | d21a39fc48c781b8bc818b537ed4bf495d5daa89 (diff) | |
pkg/compiler: allow len of var-len arrays
All netfilter subsystems use this unfortunately,
so demote this to a warning.
Diffstat (limited to 'pkg/compiler')
| -rw-r--r-- | pkg/compiler/check.go | 2 | ||||
| -rw-r--r-- | pkg/compiler/testdata/all.txt | 2 | ||||
| -rw-r--r-- | pkg/compiler/testdata/errors2.txt | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go index 16960b47e..003fe424f 100644 --- a/pkg/compiler/check.go +++ b/pkg/compiler/check.go @@ -301,7 +301,7 @@ func (comp *compiler) checkLenTarget(t *ast.Type, name, target string, fields [] desc, args, _ = comp.getArgsBase(inner, "", prog.DirIn, false) } if desc == typeArray && comp.isVarlen(args[0]) { - comp.error(t.Pos, "len target %v refer to an array with"+ + comp.warning(t.Pos, "len target %v refer to an array with"+ " variable-size elements (do you mean bytesize?)", target) } } diff --git a/pkg/compiler/testdata/all.txt b/pkg/compiler/testdata/all.txt index 6f106a25f..2bf76c28b 100644 --- a/pkg/compiler/testdata/all.txt +++ b/pkg/compiler/testdata/all.txt @@ -42,6 +42,8 @@ type len_temp2[DATA] { } foo$len_templ(a ptr[in, len_templ1[int8, int16]]) +foo$len_var0(a ptr[in, array[string]], b len[a]) +foo$len_var1(a ptr[in, array[string]], b ptr[in, len[a, int32]]) # Void type. diff --git a/pkg/compiler/testdata/errors2.txt b/pkg/compiler/testdata/errors2.txt index 67127c6ad..6902553af 100644 --- a/pkg/compiler/testdata/errors2.txt +++ b/pkg/compiler/testdata/errors2.txt @@ -64,8 +64,6 @@ foo$104(a len[parent]) ### len target parent does not exist foo$105(a ptr[in, int32], b ptr[in, array[len[a, int32]]]) foo$106(a int32, b ptr[in, csum[a, inet, int32]]) foo$107(a int32, b ptr[in, csum[c, inet, int32]]) ### csum target c does not exist -foo$108(a ptr[in, array[string]], b len[a]) ### len target a refer to an array with variable-size elements (do you mean bytesize?) -foo$109(a ptr[in, array[string]], b ptr[in, len[a, int32]]) ### len target a refer to an array with variable-size elements (do you mean bytesize?) s1 { f1 len[s2, int32] ### len target s2 does not exist |
