summaryrefslogtreecommitdiff
path: root/regress/usr.bin/xlint
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-04-27 20:41:20 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-04-27 20:41:20 +0000
commit8bd9bdcf958600e597c7ae35bcce0b923f82a3c4 (patch)
tree12aeb90d418063ac2845ef0128d65b9d6d9a9622 /regress/usr.bin/xlint
parent9dae24630c14cb491621cb89d7aab37144afa775 (diff)
Add test for "expression has null effect" warnings.
Diffstat (limited to 'regress/usr.bin/xlint')
-rw-r--r--regress/usr.bin/xlint/Makefile4
-rw-r--r--regress/usr.bin/xlint/test-20.c45
-rw-r--r--regress/usr.bin/xlint/test-20.c.exp22
3 files changed, 69 insertions, 2 deletions
diff --git a/regress/usr.bin/xlint/Makefile b/regress/usr.bin/xlint/Makefile
index e3a7bc2ef5e..9b70de5a9c8 100644
--- a/regress/usr.bin/xlint/Makefile
+++ b/regress/usr.bin/xlint/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.22 2006/04/25 01:31:46 cloder Exp $
+# $OpenBSD: Makefile,v 1.23 2006/04/27 20:41:19 otto Exp $
-TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19
+TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20
LINT= lint
LINTFLAGS?= -chapbx
diff --git a/regress/usr.bin/xlint/test-20.c b/regress/usr.bin/xlint/test-20.c
new file mode 100644
index 00000000000..25c9d3e53d0
--- /dev/null
+++ b/regress/usr.bin/xlint/test-20.c
@@ -0,0 +1,45 @@
+/* $OpenBSD: test-20.c,v 1.1 2006/04/27 20:41:19 otto Exp $ */
+
+/*
+ * Placed in the public domain by Otto Moerbeek <otto@drijf.net>.
+ *
+ * Test the 'expression has null effect warning'
+ */
+
+
+int f(int x,...)
+{
+ int p;
+ int i = (1,33), j = (p=0,p), k = (i+j, i=0);
+
+ int a = 1, b = 2, t;
+
+ t = a, a = b, b = t;
+
+ 1 + b, t = a, a = b, b = t, a + 1, b - 1;
+
+ a + t, t = b;
+
+ a + 1;
+
+ b + 1, t = t;
+
+ t = t, b + 1;
+
+ 1 + a;
+
+ 1,2,3,4,5;
+
+ a = (1,(b=2),3,4,5);
+
+ if (a + 1, b)
+ a = 2;
+
+ a ? b=1 : t;
+
+ a + 1, b = 1, t + 1;
+
+ a = (1,b,f(a,(a,b),t));
+
+ return k + k, x;
+}
diff --git a/regress/usr.bin/xlint/test-20.c.exp b/regress/usr.bin/xlint/test-20.c.exp
new file mode 100644
index 00000000000..2df33b63765
--- /dev/null
+++ b/regress/usr.bin/xlint/test-20.c.exp
@@ -0,0 +1,22 @@
+test-20.c:13: warning: expression has null effect
+test-20.c:13: warning: expression has null effect
+test-20.c:19: warning: expression has null effect
+test-20.c:19: warning: expression has null effect
+test-20.c:21: warning: expression has null effect
+test-20.c:23: warning: expression has null effect
+test-20.c:25: warning: expression has null effect
+test-20.c:29: warning: expression has null effect
+test-20.c:31: warning: expression has null effect
+test-20.c:31: warning: expression has null effect
+test-20.c:31: warning: expression has null effect
+test-20.c:31: warning: expression has null effect
+test-20.c:33: warning: expression has null effect
+test-20.c:33: warning: expression has null effect
+test-20.c:33: warning: expression has null effect
+test-20.c:35: warning: expression has null effect
+test-20.c:40: warning: expression has null effect
+test-20.c:42: warning: expression has null effect
+test-20.c:42: warning: expression has null effect
+test-20.c:42: warning: expression has null effect
+test-20.c:44: warning: expression has null effect
+Lint pass2: