diff options
Diffstat (limited to 'regress/usr.bin/xlint/test-14.c')
-rw-r--r-- | regress/usr.bin/xlint/test-14.c | 43 |
1 files changed, 43 insertions, 0 deletions
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; +} + + |