sparse/dissect: fix missing definitions for unnamed members of named types
PATCH 1/1 sparse/dissect: fix missing definitions for unnamed members of named types
Now that the Linux kernel is built with -fms-extensions, people use this feature more and more often. However, dissect.c doesn't report the definitions of members promoted from unnamed fields of named types.
This means, for example, that
$ semind search -m def ns_common.ns_id
fails without this change.
Minimal test-case:
union U { int i; };
struct S { union U; } v = { .i = 0 };Before the patch:
3:8 def s S 1:7 def s U 1:15 def m U.i int 3:23 def v v struct S 3:23 -w- v v struct S 3:30 v -w- m S.i int
After the patch:
3:8 def s S 1:7 def s U 1:15 def m U.i int 3:19 def m S.i int 3:23 def v v struct S 3:23 -w- v v struct S 3:30 v -w- m S.i int
Signed-off-by Oleg Nesterov <[email protected]>
--- dissect.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
dissect.c +12 -1
@@ -193,8 +193,19 @@ static bool deanon(struct symbol *base, struct ident *node, struct symbol *parenstatic void report_memdef (struct symbol *sym,struct symbol *mem) { mem->kind = sym && sym->type ==SYM_ENUM ?'e' :'m' ; -if (sym && mem->ident) +if (!sym) +return ; +else if (mem->ident) reporter->r_memdef (sym, mem); +else { +struct symbol *base = mem->ctype.base_type; +if (base->ident == sym->ident)// deanon()'ed +return ; +// base->inspected is T, we can override ->pos +DO_LIST (base->symbol_list, __mem, + __mem->pos = mem->pos; +report_memdef (sym, __mem)); + } }static void examine_sym_node (struct symbol *node,struct symbol *parent)
Signature · 1 line
2.52.0