From 76fc461b55cfe334e8d4be121f61fa25d079f8ba Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 16 May 2019 18:05:05 +0200 Subject: pkg/compiler: add offsetof type Similar to C offsetof gives offset of a field from the beginning of the parent struct. We have several TODOs in descriptions asking for this. --- pkg/compiler/testdata/all.txt | 2 ++ pkg/compiler/testdata/errors2.txt | 2 ++ 2 files changed, 4 insertions(+) (limited to 'pkg/compiler/testdata') diff --git a/pkg/compiler/testdata/all.txt b/pkg/compiler/testdata/all.txt index 25461ff9a..68629c685 100644 --- a/pkg/compiler/testdata/all.txt +++ b/pkg/compiler/testdata/all.txt @@ -90,6 +90,8 @@ len_expr3 { f34 bytesize[len_expr1:f11:f22:f41, int32] f35 bytesize[len_expr2:f23:f41, int32] f36 bytesize[len_expr2:f24:f41, int32] + f37 offsetof[f32, int32] + f38 offsetof[len_expr2:f21, int32] } len_expr4 { diff --git a/pkg/compiler/testdata/errors2.txt b/pkg/compiler/testdata/errors2.txt index 311be3ea9..db8f87e25 100644 --- a/pkg/compiler/testdata/errors2.txt +++ b/pkg/compiler/testdata/errors2.txt @@ -147,6 +147,8 @@ slen1 { f5 len[slen22:f, int32] ### len path slen22 does not refer to a struct f6 len[syscall, int32] ### no argument name after syscall reference f7 len[syscall:b, int32] ### len target b does not exist + f8 offsetof[parent, int32] ### offsetof must refer to fields + f9 offsetof[slen1, int32] ### offsetof must refer to fields slen2 ptr[in, array[slen2]] slen21 slen2 slen22 array[slen2] -- cgit mrf-deployment