From: Oleg Nesterov <oleg@redhat.com>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>, linux-sparse@vger.kernel.org
Subject: [PATCH 3/3] dissect: enforce MOD_TOPLEVEL if SYM_STRUCT was not defined
Date: Fri, 14 Feb 2020 12:34:07 +0100 [thread overview]
Message-ID: <20200214113407.GB31587@redhat.com> (raw)
In-Reply-To: <20200214113320.GA31578@redhat.com>
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 MOD_TOPLEVEL if !SYM_STRUCT symbol_list.
This is not 100% correct, but struct_union_enum_specifier() does the
same 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 | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dissect.c b/dissect.c
index 1465760..f60999e 100644
--- a/dissect.c
+++ b/dissect.c
@@ -305,6 +305,8 @@ static struct symbol *lookup_member(struct symbol *type, struct ident *name, int
.kind = 'm',
};
+ if (!type->symbol_list)
+ type->ctype.modifiers |= MOD_TOPLEVEL;
mem = &bad_member;
mem->ident = name;
}
--
2.5.0
next prev parent reply other threads:[~2020-02-14 11:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 11:33 [PATCH 1/3] struct_union_enum_specifier: set MOD_TOPLEVEL if toplevel(sym->scope) Oleg Nesterov
2020-02-14 11:33 ` [PATCH 2/3] dissect: fix sym_is_local(SYM_STRUCT/UNION/ENUM) Oleg Nesterov
2020-02-14 11:34 ` Oleg Nesterov [this message]
2020-02-17 21:46 ` [PATCH 1/3] struct_union_enum_specifier: set MOD_TOPLEVEL if toplevel(sym->scope) Luc Van Oostenryck
2020-02-18 10:38 ` Oleg Nesterov
2020-02-18 15:59 ` Luc Van Oostenryck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200214113407.GB31587@redhat.com \
--to=oleg@redhat.com \
--cc=gladkov.alexey@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=luc.vanoostenryck@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.