summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcloder <cloder@openbsd.org>2005-12-09 04:30:58 +0000
committercloder <cloder@openbsd.org>2005-12-09 04:30:58 +0000
commitb742d63dbcb5865aab107376bca6600e5bb93dd8 (patch)
treeafc476cadcc32bb53e50504bbcdde32d42c52edf
parentDo not warn about assignment in conditional context if the assignment (diff)
downloadwireguard-openbsd-b742d63dbcb5865aab107376bca6600e5bb93dd8.tar.xz
wireguard-openbsd-b742d63dbcb5865aab107376bca6600e5bb93dd8.zip
Add regression test for assignment in conditional context
-rw-r--r--regress/usr.bin/xlint/Makefile4
-rw-r--r--regress/usr.bin/xlint/test-12.c27
-rw-r--r--regress/usr.bin/xlint/test-12.c.exp2
3 files changed, 31 insertions, 2 deletions
diff --git a/regress/usr.bin/xlint/Makefile b/regress/usr.bin/xlint/Makefile
index 68f0d66fd93..92e351b3cdf 100644
--- a/regress/usr.bin/xlint/Makefile
+++ b/regress/usr.bin/xlint/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.12 2005/12/09 03:36:14 cloder Exp $
+# $OpenBSD: Makefile,v 1.13 2005/12/09 04:30:58 cloder Exp $
-TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 11
+TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 11 12
LINT= lint
LINTFLAGS?= -chapbx
diff --git a/regress/usr.bin/xlint/test-12.c b/regress/usr.bin/xlint/test-12.c
new file mode 100644
index 00000000000..11a43e84235
--- /dev/null
+++ b/regress/usr.bin/xlint/test-12.c
@@ -0,0 +1,27 @@
+/* $OpenBSD: test-12.c,v 1.1 2005/12/09 04:30:58 cloder Exp $ */
+
+/*
+ * Placed in the public domain by Chad Loder <cloder@openbsd.org>.
+ *
+ * Test lint warnings regarding assignment in conditional context.
+ */
+#include <limits.h>
+
+/* ARGSUSED */
+int
+main(int argc, char *argv[])
+{
+ int a = 0;
+
+ if (a = argc) /* should warn */
+ return 1;
+
+ a++;
+
+ if ((a = argc)) /* should not warn */
+ return 1;
+
+ return 0;
+}
+
+
diff --git a/regress/usr.bin/xlint/test-12.c.exp b/regress/usr.bin/xlint/test-12.c.exp
new file mode 100644
index 00000000000..e2d0e9c0267
--- /dev/null
+++ b/regress/usr.bin/xlint/test-12.c.exp
@@ -0,0 +1,2 @@
+test-12.c(16): warning: assignment in conditional context
+Lint pass2: