aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/backend/int-cond.c
diff options
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>2012-08-19 16:52:16 +0200
committerPekka Enberg <penberg@kernel.org>2012-08-19 18:10:34 +0300
commite03a53b13e76c8049406eca28c843da33d3e394d (patch)
tree1fa611f4ceb1e99ddb09ecc6b149a45619c970e4 /validation/backend/int-cond.c
parent33844e787a0ed80d04b2917042fec50ccf4c91dd (diff)
downloadsparse-dev-e03a53b13e76c8049406eca28c843da33d3e394d.tar.gz
sparse, llvm: convert the condition of branch/select to bool
LLVM expects the first argument of "br" and "select" to be of type i1, so add an "icmp ne <srcty> %src, 0" for other types. Cc: Christopher Li <sparse@chrisli.org> Cc: Jeff Garzik <jgarzik@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'validation/backend/int-cond.c')
-rw-r--r--validation/backend/int-cond.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/validation/backend/int-cond.c b/validation/backend/int-cond.c
new file mode 100644
index 00000000..48b25a77
--- /dev/null
+++ b/validation/backend/int-cond.c
@@ -0,0 +1,30 @@
+static long foo(long a, long b, long c)
+{
+ return a? b:c;
+}
+
+static long foo_bool(_Bool a, long b, long c)
+{
+ return a? b:c;
+}
+
+static long bar(long a, long b, long c)
+{
+ if (a)
+ return b;
+ else
+ return b + c;
+}
+
+static long bar_bool(_Bool a, long b, long c)
+{
+ if (a)
+ return b;
+ else
+ return b + c;
+}
+
+/*
+ * check-name: Non-bool condition values in branch/select
+ * check-command: ./sparsec -c $file -o tmp.o
+ */