From bde8fd413bd79491702c8ff7103f5069745574e9 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 28 Dec 2023 11:36:49 +0100 Subject: pkg/compiler: extend parent reference support in len Earlier only len[parent, T] was supported and meant the size of the whole structure. Logically, len[parent:b, T] should be equivalent to just len[b, T]. Let len[parent:parent:a, T] refer to the structure that encloses the current one. Support len fields inside unions. --- sys/test/test.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'sys') diff --git a/sys/test/test.txt b/sys/test/test.txt index 1b63cd525..788eb8484 100644 --- a/sys/test/test.txt +++ b/sys/test/test.txt @@ -486,6 +486,37 @@ offsetof0 { o7 offsetof[f7, int32] } +parent_parent_helper { + f1 array[int32, 8] + f2 parent_parent_length + f3 ptr[in, parent_parent_length] +} + +parent_parent_length { + f1 len[parent:parent:f1, int32] +} + +test$length32(a0 ptr[in, parent_parent_helper]) + +one_parent_length { + f1 array[int32, 4] + f2 len[parent:f1, int32] +} + +test$length33(a0 ptr[in, one_parent_length]) + +parent_union_struct { + f1 array[int32, 4] + f2 ptr[in, parent_union] +} + +parent_union [ + u1 len[parent:parent:f1, int32] + u2 int32 +] + +test$length34(a0 ptr[in, parent_union_struct]) + # Big endian test$end0(a0 ptr[in, syz_end_int_struct]) -- cgit mrf-deployment