From 0f164300b33f421468051a8815711503a34cd49c Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Fri, 10 Nov 2023 17:56:02 +0100 Subject: compiler: support const as int first argument This commit adds support for the following syntax: int8[constant] as an equivalent to: const[constant, int8] The goal is to have a unified const/flags definition that we can use in templates. For example: type template[CLASS, ...] { class int8:3[CLASS] // ... } type singleClassType template[SINGLE_CONST] type subClassType template[abc_class_flags] In this example, the CLASS template field can be either a constant or a flag. This is especially useful when defining both a generic instance of the template as well as specialized instances (ex. bpf_alu_ops and bpf_add_op). Signed-off-by: Paul Chaignon --- pkg/compiler/testdata/errors.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'pkg/compiler/testdata/errors.txt') diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt index bc3054a64..84cfad221 100644 --- a/pkg/compiler/testdata/errors.txt +++ b/pkg/compiler/testdata/errors.txt @@ -88,7 +88,6 @@ 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]) ### first argument of int32 needs to be a range or flag foo$17(a ptr[in, int32]) foo$18(a ptr[in, int32[2:3]]) foo$19(a ptr[in, int32[opt]]) @@ -134,7 +133,7 @@ foo$64(a ptr[in, flags[f1[int32], int32]]) ### flags argument has subargs foo$65(a int32, b len[1]) ### unexpected int 1 for len target argument of len type, expect identifier foo$66(a int32, b len[a:1]) ### unexpected int 1 after colon, expect identifier foo$67(x int32[1:2:3, opt]) ### unexpected ':' -foo$68(a int32[15, 2]) ### first argument of int32 needs to be a range or flag +foo$68(a int32[15, 2]) ### align argument of int32 is not supported unless first argument is a range foo$69() (foo) ### unknown syscall foo$69 attribute foo foo$70() ("foo") ### unexpected string "foo", expect attribute foo$71() (42) ### unexpected int 42, expect attribute -- cgit mrf-deployment