aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-22 16:50:12 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-22 18:24:41 +0100
commit7b6694c40b3329b858f89b91b35e6e64f1c9c4f6 (patch)
treeab8d971cd47b016fcdcaca80f35570b3c5d4f2cd /validation
parente4a026a56afbba1f722e541b8fbb71f65fc80a15 (diff)
downloadsparse-dev-7b6694c40b3329b858f89b91b35e6e64f1c9c4f6.tar.gz
warn if testing the address of a function
Testing the address of a function is quite suspicious: it's most probably the sign of an error somewhere. Furthermore, such uses always evaluate to true. So, add a warning about such use (but only if -Waddress was given). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/cond-address-function.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/validation/cond-address-function.c b/validation/cond-address-function.c
new file mode 100644
index 00000000..9a143a00
--- /dev/null
+++ b/validation/cond-address-function.c
@@ -0,0 +1,18 @@
+extern void func(void);
+
+int global_function(void)
+{
+ if (func)
+ return 1;
+ return 0;
+}
+
+/*
+ * check-name: cond-address-function
+ * check-command: test-linearize -Wno-decl -Waddress $file
+ * check-output-ignore
+ *
+ * check-error-start
+cond-address-function.c:5:13: warning: the address of a function will always evaluate as true
+ * check-error-end
+ */