From 97bc55cead011ec5d60af8c3696ee2724b78fea5 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 17 Mar 2020 17:13:26 +0100 Subject: pkg/compiler: check that flags values fit into base type flags[foo, int8] foo = 0x12345678 is always an error, detect these cases. Found some bugs in mptcp, packet sockets, kvm. --- pkg/compiler/testdata/errors2.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pkg/compiler/testdata') diff --git a/pkg/compiler/testdata/errors2.txt b/pkg/compiler/testdata/errors2.txt index 4ec52d6cb..b862c4951 100644 --- a/pkg/compiler/testdata/errors2.txt +++ b/pkg/compiler/testdata/errors2.txt @@ -274,6 +274,9 @@ foo$530(a ptr[in, const[0x1ab, int8]]) ### const val 0x1ab does not fit into 8 b foo$531(a ptr[in, const[0xffffffffffffffab, int8]]) foo$532(a ptr[in, const[0x7234567812345678, int64]]) foo$533(a ptr[in, const[0x12, int8:4]]) ### const val 0x12 does not fit into 4 bits +foo$534(a ptr[in, flags[large_flags, int8]]) ### large_flags U16_MAX=0xffff doesn't fit into 8 bits + +large_flags = U8_MAX, U16_MAX type type500 proc[C1, 8, int8] ### values starting from 1 with step 8 overflow base type for 32 procs type type501 int8 ### unused type type501 -- cgit mrf-deployment