summaryrefslogtreecommitdiff
path: root/regress/usr.bin/xlint
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-12-16 03:02:23 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-12-16 03:02:23 +0000
commitf1d156467e7c6ba345a1cc46106184f851c0e0f5 (patch)
tree6f1024a428288d83d9611243c892586f7b8edfa1 /regress/usr.bin/xlint
parent8bd3ba17514484d2fad65e72dfe33a2999ba1ace (diff)
Add a regression test for lint catching division by zero.
Diffstat (limited to 'regress/usr.bin/xlint')
-rw-r--r--regress/usr.bin/xlint/Makefile4
-rw-r--r--regress/usr.bin/xlint/test-15.c46
-rw-r--r--regress/usr.bin/xlint/test-15.c.exp9
3 files changed, 57 insertions, 2 deletions
diff --git a/regress/usr.bin/xlint/Makefile b/regress/usr.bin/xlint/Makefile
index e13514f4657..ac50bd29082 100644
--- a/regress/usr.bin/xlint/Makefile
+++ b/regress/usr.bin/xlint/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.17 2005/12/12 23:37:51 cloder Exp $
+# $OpenBSD: Makefile,v 1.18 2005/12/16 03:02:22 cloder Exp $
-TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 12 13 14
+TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 12 13 14 15
LINT= lint
LINTFLAGS?= -chapbx
diff --git a/regress/usr.bin/xlint/test-15.c b/regress/usr.bin/xlint/test-15.c
new file mode 100644
index 00000000000..3ff79a3b768
--- /dev/null
+++ b/regress/usr.bin/xlint/test-15.c
@@ -0,0 +1,46 @@
+/* $OpenBSD: test-15.c,v 1.1 2005/12/16 03:02:22 cloder Exp $ */
+
+/*
+ * Placed in the public domain by Chad Loder <cloder@openbsd.org>.
+ *
+ * Test lint dealing with division by zero.
+ */
+
+/* ARGSUSED */
+void dbzd(double d) { }
+/* ARGSUSED */
+void dbzf(float f) { }
+/* ARGSUSED */
+void dbzi(int i) { }
+/* ARGSUSED */
+void dbzl(long L) { }
+
+/*ARGSUSED*/
+int
+main(int argc, char* argv[])
+{
+ double d;
+ long L;
+ int i;
+ float f;
+
+ i = 0 / 0;
+ f = 0.0f / 0.0f;
+ d = 0.0 / 0.0;
+ L = 0L / 0L;
+
+ dbzd(0.0 / 0.0);
+ dbzf(0.0f / 0.0f);
+ dbzi(0 / 0);
+ dbzl(0L / 0L);
+
+ i++;
+ f++;
+ d++;
+ L++;
+
+ return 0;
+}
+
+
+
diff --git a/regress/usr.bin/xlint/test-15.c.exp b/regress/usr.bin/xlint/test-15.c.exp
new file mode 100644
index 00000000000..895f27b0eb0
--- /dev/null
+++ b/regress/usr.bin/xlint/test-15.c.exp
@@ -0,0 +1,9 @@
+test-15.c:27: warning: division by 0
+test-15.c:28: warning: division by 0
+test-15.c:29: warning: division by 0
+test-15.c:30: warning: division by 0
+test-15.c:32: warning: division by 0
+test-15.c:33: warning: division by 0
+test-15.c:34: warning: division by 0
+test-15.c:35: warning: division by 0
+Lint pass2: