aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-22 15:38:49 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-22 18:24:41 +0100
commitb5867a33b62c04811784c6fc233c601a4f2b0841 (patch)
tree3aac0baf1179d23128b5b94aff5538a2fe7046b6 /validation
parent4480ef07d1187395ea8b277174ac2545254b40f0 (diff)
downloadsparse-dev-b5867a33b62c04811784c6fc233c601a4f2b0841.tar.gz
fix evaluation of a function or array symbol in conditionals
Functions and arrays degenerate as pointers in most context but this wasn't done in the case of conditionals. As a result the value of the conditional after linearization was invalid. Fix this by calling degenerate() in evaluate_conditional(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/cond-address.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/validation/cond-address.c b/validation/cond-address.c
new file mode 100644
index 00000000..2a69f4b9
--- /dev/null
+++ b/validation/cond-address.c
@@ -0,0 +1,14 @@
+extern void f(void);
+extern int a[];
+
+int foo(void) { if (f) return 1; return 0; }
+int bar(void) { if (a) return 1; return 0; }
+int qux(void) { if (f && a) return 1; return 0; }
+
+/*
+ * check-name: cond-address.c
+ * check-command: test-linearize -Wno-decl $file
+ * check-output-ignore
+ *
+ * check-excludes: VOID
+ */