From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Josh Triplett <josh@joshtriplett.org>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 2/3] add helper: is_scalar_type()
Date: Sun, 29 Jan 2017 12:34:08 +0100 [thread overview]
Message-ID: <20170129113409.9834-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170129113409.9834-1-luc.vanoostenryck@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
symbol.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/symbol.h b/symbol.h
index 9b3f1604e..b0176bc5e 100644
--- a/symbol.h
+++ b/symbol.h
@@ -372,6 +372,28 @@ static inline int is_bool_type(struct symbol *type)
return type == &bool_ctype;
}
+static inline int is_scalar_type(struct symbol *type)
+{
+ if (type->type == SYM_NODE)
+ type = type->ctype.base_type;
+ switch (type->type) {
+ case SYM_ENUM:
+ case SYM_BITFIELD:
+ case SYM_PTR:
+ case SYM_ARRAY: // OK, will be a PTR after conversion
+ case SYM_FN:
+ case SYM_RESTRICT: // OK, always integer types
+ return 1;
+ default:
+ break;
+ }
+ if (type->ctype.base_type == &int_type)
+ return 1;
+ if (type->ctype.base_type == &fp_type)
+ return 1;
+ return 0;
+}
+
static inline int is_function(struct symbol *type)
{
return type && type->type == SYM_FN;
--
2.11.0
next prev parent reply other threads:[~2017-01-29 15:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-29 11:34 [PATCH 0/3] validate expression's type in conditionals Luc Van Oostenryck
2017-01-29 11:34 ` [PATCH 1/3] fix conditional context test case with void Luc Van Oostenryck
2017-01-29 11:34 ` Luc Van Oostenryck [this message]
2017-01-29 11:34 ` [PATCH 3/3] validate expression's type in conditionals 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=20170129113409.9834-3-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-sparse@vger.kernel.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).