From f1d156467e7c6ba345a1cc46106184f851c0e0f5 Mon Sep 17 00:00:00 2001 From: Chad Loder Date: Fri, 16 Dec 2005 03:02:23 +0000 Subject: Add a regression test for lint catching division by zero. --- regress/usr.bin/xlint/Makefile | 4 ++-- regress/usr.bin/xlint/test-15.c | 46 +++++++++++++++++++++++++++++++++++++ regress/usr.bin/xlint/test-15.c.exp | 9 ++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 regress/usr.bin/xlint/test-15.c create mode 100644 regress/usr.bin/xlint/test-15.c.exp 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 . + * + * 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: -- cgit v1.2.3