aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorJohn Levon <levon@movementarian.org>2018-11-29 10:42:51 +0000
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-12-01 02:16:24 +0100
commit648380c13ecaaa95c9dfbd500039cd9007ec3c20 (patch)
tree3e6d634f8549a13d97bdbe0fba39aed97364eb9c /validation
parenta0f34e0fd2a44016ef668e19187a342c5f4edf45 (diff)
downloadsparse-dev-648380c13ecaaa95c9dfbd500039cd9007ec3c20.tar.gz
Conditionalize 'warning: non-ANSI function ...'
Sparse unconditionally issues warnings about non-ANSI function declarations & definitions. However, some environments have large amounts of legacy headers that are pre-ANSI, and can't easily be changed. These generate a lot of useless warnings. Fix this by using the options flags -Wstrict-prototypes & -Wold-style-definition to conditionalize these warnings. Signed-off-by: John Levon <levon@movementarian.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/old-style-definition0.c14
-rw-r--r--validation/old-style-definition1.c18
-rw-r--r--validation/strict-prototypes0.c7
-rw-r--r--validation/strict-prototypes1.c14
4 files changed, 53 insertions, 0 deletions
diff --git a/validation/old-style-definition0.c b/validation/old-style-definition0.c
new file mode 100644
index 00000000..eb522aa6
--- /dev/null
+++ b/validation/old-style-definition0.c
@@ -0,0 +1,14 @@
+extern int foo(int a, void *b);
+
+int foo(a, b)
+ int a;
+ void *b;
+{
+ if (b)
+ return a;
+}
+
+/*
+ * check-name: old-stype-definition disabled
+ * check-command: sparse -Wno-old-style-definition $file
+ */
diff --git a/validation/old-style-definition1.c b/validation/old-style-definition1.c
new file mode 100644
index 00000000..f65d7dfe
--- /dev/null
+++ b/validation/old-style-definition1.c
@@ -0,0 +1,18 @@
+extern int foo(int a, void *b);
+
+int foo(a, b)
+ int a;
+ void *b;
+{
+ if (b)
+ return a;
+}
+
+/*
+ * check-name: old-stype-definition enabled
+ * check-command: sparse -Wold-style-definition $file
+ *
+ * check-error-start
+old-style-definition1.c:4:9: warning: non-ANSI definition of function 'foo'
+ * check-error-end
+ */
diff --git a/validation/strict-prototypes0.c b/validation/strict-prototypes0.c
new file mode 100644
index 00000000..e320846b
--- /dev/null
+++ b/validation/strict-prototypes0.c
@@ -0,0 +1,7 @@
+extern void func1();
+extern void myfunction(), myfunc2();
+
+/*
+ * check-name: strict-prototypes disabled
+ * check-command: sparse -Wno-strict-prototypes $file
+ */
diff --git a/validation/strict-prototypes1.c b/validation/strict-prototypes1.c
new file mode 100644
index 00000000..7e4ce6bb
--- /dev/null
+++ b/validation/strict-prototypes1.c
@@ -0,0 +1,14 @@
+extern void func0();
+extern void func1(), func2();
+
+/*
+ * check-name: strict-prototypes enabled
+ * check-command: sparse -Wstrict-prototypes $file
+ * check-known-to-fail
+ *
+ * check-error-start
+strict-prototypes1.c:1:18: warning: non-ANSI function declaration of function 'func0'
+strict-prototypes1.c:2:18: warning: non-ANSI function declaration of function 'func1'
+strict-prototypes1.c:2:27: warning: non-ANSI function declaration of function 'func2'
+ * check-error-end
+ */