aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/backend/compare-with-null.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-12 00:45:37 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-11-17 10:04:37 +0100
commitaccf7112191ba29f0366c8a10332a8a63644db50 (patch)
tree6185f5a5cd930942bdc22e3e21b954a43aaaf518 /validation/backend/compare-with-null.c
parentf8f27931b9b1118363b364b04fb09526c62d21fb (diff)
downloadsparse-dev-accf7112191ba29f0366c8a10332a8a63644db50.tar.gz
llvm: fix type in comparison with an address constant
Since sparse's constant are typeless comparing a pointer with an address constant lack correct type information. Fix this by casting the constant to the same type as the LHS. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/backend/compare-with-null.c')
-rw-r--r--validation/backend/compare-with-null.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/validation/backend/compare-with-null.c b/validation/backend/compare-with-null.c
new file mode 100644
index 00000000..e23562bc
--- /dev/null
+++ b/validation/backend/compare-with-null.c
@@ -0,0 +1,12 @@
+int tstv(void *p) { return !p; }
+int cmpv(void *p) { return p == ((void*)0); }
+
+int tsti(int *p) { return !p; }
+int cmpi(int *p) { return p == ((int *)0); }
+int cmpx(int *p) { return p == ((void*)0); }
+
+/*
+ * check-name: compare-with-null
+ * check-command: sparsec -Wno-decl -c $file -o tmp.o
+ * check-output-ignore
+ */