linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Christopher Li <sparse@chrisli.org>,
	Dibyendu Majumdar <mobile@majumdar.org.uk>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [RFC PATCH 4/4] fix promotion of struct & union
Date: Fri, 18 Aug 2017 00:35:58 +0200	[thread overview]
Message-ID: <20170817223558.21258-5-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170817223558.21258-1-luc.vanoostenryck@gmail.com>

---
 linearize.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/linearize.c b/linearize.c
index 485d8eeec..a92a0e095 100644
--- a/linearize.c
+++ b/linearize.c
@@ -957,6 +957,8 @@ static int linearize_address_gen(struct entrypoint *ep,
  */
 static inline int is_promotable(struct symbol *type)
 {
+	struct symbol *member;
+
 	if (type->type == SYM_NODE)
 		type = type->ctype.base_type;
 	switch (type->type) {
@@ -967,7 +969,13 @@ static inline int is_promotable(struct symbol *type)
 		return 1;
 	case SYM_STRUCT:
 	case SYM_UNION:
-		return type->bit_size <= long_ctype.bit_size;
+		if (type->bit_size > long_ctype.bit_size)
+			return 0;
+		FOR_EACH_PTR(type->symbol_list, member) {
+			if (!is_promotable(member))
+				return 0;
+		} END_FOR_EACH_PTR(member);
+		return 1;
 	default:
 		break;
 	}
-- 
2.14.0


  parent reply	other threads:[~2017-08-17 22:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-17 22:35 [RFC PATCH 0/4] simple, registrable, promotable & friends Luc Van Oostenryck
2017-08-17 22:35 ` [RFC PATCH 2/4] fold is_simple_var() into simple_access() Luc Van Oostenryck
2017-08-17 22:35 ` [RFC PATCH 3/4] rename 'simple_{var,access}' by promatable_...' Luc Van Oostenryck
2017-08-17 22:35 ` Luc Van Oostenryck [this message]
2017-08-19 11:28 ` [RFC PATCH 0/4] simple, registrable, promotable & friends Christopher Li

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=20170817223558.21258-5-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=mobile@majumdar.org.uk \
    --cc=sparse@chrisli.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).