From dd4fcef5a270fc39a56c0be8122fc6f18314f3cd Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 17 Feb 2018 16:51:52 +0100 Subject: pkg/compiler: allow len of var-len arrays All netfilter subsystems use this unfortunately, so demote this to a warning. --- pkg/compiler/check.go | 2 +- pkg/compiler/testdata/all.txt | 2 ++ pkg/compiler/testdata/errors2.txt | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'pkg') 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 -- cgit mrf-deployment