summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-12-12 23:37:52 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-12-12 23:37:52 +0000
commit25940ee1f068ec6dba0601e1979719912002325d (patch)
tree6f888eab020c6d7b444a368197fbc5343507a2ad
parent7563c3a21b2756c5ee3935624d8915f3fc842fd2 (diff)
Regression test for constant in conditional context
-rw-r--r--regress/usr.bin/xlint/Makefile4
-rw-r--r--regress/usr.bin/xlint/test-14.c43
-rw-r--r--regress/usr.bin/xlint/test-14.c.exp3
3 files changed, 48 insertions, 2 deletions
diff --git a/regress/usr.bin/xlint/Makefile b/regress/usr.bin/xlint/Makefile
index da9aabffe49..e13514f4657 100644
--- a/regress/usr.bin/xlint/Makefile
+++ b/regress/usr.bin/xlint/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.16 2005/12/10 19:19:49 cloder Exp $
+# $OpenBSD: Makefile,v 1.17 2005/12/12 23:37:51 cloder Exp $
-TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 12 13
+TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 12 13 14
LINT= lint
LINTFLAGS?= -chapbx
diff --git a/regress/usr.bin/xlint/test-14.c b/regress/usr.bin/xlint/test-14.c
new file mode 100644
index 00000000000..a9e12daaed1
--- /dev/null
+++ b/regress/usr.bin/xlint/test-14.c
@@ -0,0 +1,43 @@
+/* $OpenBSD: test-14.c,v 1.1 2005/12/12 23:37:51 cloder Exp $ */
+
+/*
+ * Placed in the public domain by Chad Loder <cloder@openbsd.org>.
+ *
+ * Test lint warnings regarding constant in conditional contexts.
+ */
+
+/* ARGSUSED */
+int
+main(int argc, char *argv[])
+{
+ do {
+ argc++;
+ } while (0); /* do not warn */
+
+ do {
+ if (argc++)
+ break;
+ } while (1); /* do not warn */
+
+
+ do {
+ if (argc++)
+ break;
+ } while (2); /* warn because of 2 */
+
+ if (0) { /* do not warn */
+ argc++;
+ }
+
+ if (1) { /* do not warn */
+ argc++;
+ }
+
+ if (argc && 1) { /* warn because of compound expression */
+ argc++;
+ }
+
+ return 0;
+}
+
+
diff --git a/regress/usr.bin/xlint/test-14.c.exp b/regress/usr.bin/xlint/test-14.c.exp
new file mode 100644
index 00000000000..bd35832774c
--- /dev/null
+++ b/regress/usr.bin/xlint/test-14.c.exp
@@ -0,0 +1,3 @@
+test-14.c:26: warning: constant in conditional context
+test-14.c:36: warning: constant in conditional context
+Lint pass2: