From 4efd46f20fcf44af31c81f62f562cecb50653451 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 15 Nov 2024 15:39:13 +0100 Subject: pkg/compiler: allow recursion via arrays Permit structs to recursively contain itself in arrays. This is needed for netlink. Amusingly several netlink policies contain itself. --- pkg/compiler/compiler.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'pkg/compiler/compiler.go') diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index 3f10ae5fe..978255219 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -65,6 +65,7 @@ func createCompiler(desc *ast.Description, target *targets.Target, eh ast.ErrorH structVarlen: make(map[string]bool), structTypes: make(map[string]prog.Type), structFiles: make(map[*ast.Struct]map[string]ast.Pos), + recursiveQuery: make(map[ast.Node]bool), builtinConsts: map[string]uint64{ "PTR_SIZE": target.PtrSize, }, @@ -135,11 +136,12 @@ type compiler struct { usedTypedefs map[string]bool brokenTypedefs map[string]bool - structVarlen map[string]bool - structTypes map[string]prog.Type - structFiles map[*ast.Struct]map[string]ast.Pos - builtinConsts map[string]uint64 - fileMeta map[string]Meta + structVarlen map[string]bool + structTypes map[string]prog.Type + structFiles map[*ast.Struct]map[string]ast.Pos + builtinConsts map[string]uint64 + fileMeta map[string]Meta + recursiveQuery map[ast.Node]bool } type warn struct { -- cgit mrf-deployment