Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: test how NOTREACHED af...



details:   https://anonhg.NetBSD.org/src/rev/0ad3a899ea36
branches:  trunk
changeset: 985269:0ad3a899ea36
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 15 21:21:13 2021 +0000

description:
tests/lint: test how NOTREACHED affects the unreachable warning

Inspired by lib/libedit/readline.c 1.159 from 2021-08-15.

diffstat:

 tests/usr.bin/xlint/lint1/msg_193.c   |  37 ++++++++++++++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/msg_193.exp |   2 +
 2 files changed, 38 insertions(+), 1 deletions(-)

diffs (57 lines):

diff -r d746cec57181 -r 0ad3a899ea36 tests/usr.bin/xlint/lint1/msg_193.c
--- a/tests/usr.bin/xlint/lint1/msg_193.c       Sun Aug 15 17:09:03 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.c       Sun Aug 15 21:21:13 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_193.c,v 1.12 2021/07/11 19:30:56 rillig Exp $      */
+/*     $NetBSD: msg_193.c,v 1.13 2021/08/15 21:21:13 rillig Exp $      */
 # 3 "msg_193.c"
 
 // Test for message: statement not reached [193]
@@ -616,3 +616,38 @@
 /* TODO: switch */
 
 /* TODO: system-dependent constant expression (see tn_system_dependent) */
+
+void suppressed(void);
+
+void
+lint_annotation_NOTREACHED(void)
+{
+       if (0) {
+               /* expect+1: warning: statement not reached [193] */
+               unreachable();
+       }
+
+       if (0) {
+               /* NOTREACHED */
+               suppressed();
+       }
+
+       if (0)
+               /* NOTREACHED */
+               suppressed();
+
+       if (1) {
+               reachable();
+       }
+
+       if (1) {
+               /* NOTREACHED */
+               suppressed();
+       }
+
+       /* FIXME: The 'if' statement _is_ reached. */
+       /* expect+1: warning: statement not reached [193] */
+       if (1)
+               /* NOTREACHED */
+               suppressed();
+}
diff -r d746cec57181 -r 0ad3a899ea36 tests/usr.bin/xlint/lint1/msg_193.exp
--- a/tests/usr.bin/xlint/lint1/msg_193.exp     Sun Aug 15 17:09:03 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_193.exp     Sun Aug 15 21:21:13 2021 +0000
@@ -85,3 +85,5 @@
 msg_193.c(580): warning: label 'six' unused in function 'test_goto_numbers_alphabetically' [232]
 msg_193.c(597): warning: statement not reached [193]
 msg_193.c(606): warning: statement not reached [193]
+msg_193.c(627): warning: statement not reached [193]
+msg_193.c(650): warning: statement not reached [193]



Home | Main Index | Thread Index | Old Index