All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dissect: enforce toplevel() if SYM_STRUCT was not defined
@ 2020-02-27 15:21 Oleg Nesterov
  2020-03-02 13:17 ` Luc Van Oostenryck
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2020-02-27 15:21 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: Alexey Gladkov, linux-sparse

A separate change for documentation purposes.

Test-case:

	void func(void)
	{
		struct UNDEFINED x;
		x.member = 0;
	}

output:

   1:6                    def   f func                             void ( ... )
   3:26  func             def . v x                                struct UNDEFINED
   4:9   func             -w- . v x                                struct UNDEFINED
   4:10  func             -w- . m UNDEFINED.member                 bad type

but in this case is_sym_local(UNDEFINED) = F makes more sense, most
probably this struct was defined somewhere else but __sparse() didn't
see its definition.

Change lookup_member() to set type->scope = file_scope if !symbol_list.
This is not 100% correct, but struct_union_enum_specifier() does the
same check with the following comment:

	// The following test is actually wrong for empty
	// structs, but (1) they are not C99, (2) gcc does
	// the same thing, and (3) it's easier.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 dissect.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/dissect.c b/dissect.c
index c48214b9..1970e46f 100644
--- a/dissect.c
+++ b/dissect.c
@@ -304,6 +304,9 @@ static struct symbol *lookup_member(struct symbol *type, struct ident *name, int
 			.kind = 'm',
 		};
 
+		if (!type->symbol_list)
+			type->scope = file_scope;
+
 		mem = &bad_member;
 		mem->ident = name;
 	}
-- 
2.25.1.362.g51ebf55

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dissect: enforce toplevel() if SYM_STRUCT was not defined
  2020-02-27 15:21 [PATCH] dissect: enforce toplevel() if SYM_STRUCT was not defined Oleg Nesterov
@ 2020-03-02 13:17 ` Luc Van Oostenryck
  0 siblings, 0 replies; 2+ messages in thread
From: Luc Van Oostenryck @ 2020-03-02 13:17 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Alexey Gladkov, linux-sparse

On Thu, Feb 27, 2020 at 04:21:15PM +0100, Oleg Nesterov wrote:
> A separate change for documentation purposes.

Thanks.
Applied & pushed.

-- Luc 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-02 13:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-27 15:21 [PATCH] dissect: enforce toplevel() if SYM_STRUCT was not defined Oleg Nesterov
2020-03-02 13:17 ` Luc Van Oostenryck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.