summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-12-09 04:30:59 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-12-09 04:30:59 +0000
commit2b562341e438086c432ea4d52f1b21163d513dea (patch)
treeff54002156e644ca67ecbb8b7028b3f225dfab89
parent06dd4507db83fc57adee7c1cc5f2020cc08b0717 (diff)
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: