diff options
author | Chad Loder <cloder@cvs.openbsd.org> | 2006-04-20 03:39:15 +0000 |
---|---|---|
committer | Chad Loder <cloder@cvs.openbsd.org> | 2006-04-20 03:39:15 +0000 |
commit | 1b41be40e9d1c4827379ca50c973e334b6e3d638 (patch) | |
tree | 0f49a03f98c460c89d659fb9caee02be4edbb6cf /regress | |
parent | 60376819b7538372032e8f2efed2f7613c91c7e0 (diff) |
Test case for unreachable breaks
Diffstat (limited to 'regress')
-rw-r--r-- | regress/usr.bin/xlint/Makefile | 4 | ||||
-rw-r--r-- | regress/usr.bin/xlint/test-17.c | 44 | ||||
-rw-r--r-- | regress/usr.bin/xlint/test-17.c.exp | 3 |
3 files changed, 49 insertions, 2 deletions
diff --git a/regress/usr.bin/xlint/Makefile b/regress/usr.bin/xlint/Makefile index e00b8e5e9bd..7919d193e7f 100644 --- a/regress/usr.bin/xlint/Makefile +++ b/regress/usr.bin/xlint/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.19 2006/03/20 05:06:37 cloder Exp $ +# $OpenBSD: Makefile,v 1.20 2006/04/20 03:39:14 cloder Exp $ -TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 +TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 LINT= lint LINTFLAGS?= -chapbx diff --git a/regress/usr.bin/xlint/test-17.c b/regress/usr.bin/xlint/test-17.c new file mode 100644 index 00000000000..58870ab8a7e --- /dev/null +++ b/regress/usr.bin/xlint/test-17.c @@ -0,0 +1,44 @@ + /* $OpenBSD: test-17.c,v 1.1 2006/04/20 03:39:14 cloder Exp $ */ + +/* + * Placed in the public domain by Chad Loder <cloder@openbsd.org>. + * + * Test lint dealing with unreachable break statements. + */ + +/* ARGSUSED */ +int +main(int argc, char* argv[]) +{ + int a = 0; + + switch (argc) + { + case 1: + a = 1; + return 1; + break; /* should not warn */ + case 2: + a = 2; + while (a < 5) { + a++; + break; + break; /* should warn */ + } + break; + default: + break; + } + + while (argc < 5) { + if (argc ) { + return 1; + break; /* should warn */ + } + + argc++; + break; + } + + return a; +} diff --git a/regress/usr.bin/xlint/test-17.c.exp b/regress/usr.bin/xlint/test-17.c.exp new file mode 100644 index 00000000000..227bde47683 --- /dev/null +++ b/regress/usr.bin/xlint/test-17.c.exp @@ -0,0 +1,3 @@ +test-17.c:26: warning: statement not reached +test-17.c:36: warning: statement not reached +Lint pass2: |