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: demonstrate wrong warn...



details:   https://anonhg.NetBSD.org/src/rev/f0ef6c004e1c
branches:  trunk
changeset: 1019346:f0ef6c004e1c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 07 16:40:20 2021 +0000

description:
tests/lint: demonstrate wrong warning for array subscript

Seen in usr.bin/indent/lexi.c.

diffstat:

 tests/usr.bin/xlint/lint1/msg_168.c   |  15 ++++++++++++++-
 tests/usr.bin/xlint/lint1/msg_168.exp |   2 ++
 2 files changed, 16 insertions(+), 1 deletions(-)

diffs (33 lines):

diff -r dda20436a8c6 -r f0ef6c004e1c tests/usr.bin/xlint/lint1/msg_168.c
--- a/tests/usr.bin/xlint/lint1/msg_168.c       Sun Mar 07 16:25:06 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_168.c       Sun Mar 07 16:40:20 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_168.c,v 1.2 2021/01/24 16:12:45 rillig Exp $       */
+/*     $NetBSD: msg_168.c,v 1.3 2021/03/07 16:40:20 rillig Exp $       */
 # 3 "msg_168.c"
 
 // Test for message: array subscript cannot be > %d: %ld [168]
@@ -27,3 +27,16 @@
        print_char(buf[19]);
        print_char(buf[20]);    /* expect: 168 */
 }
+
+void
+array_with_c99_initializer(void)
+{
+       static const char *const to_roman[] = {
+           ['0'] = "undefined",
+           ['5'] = "V",
+           ['9'] = "IX"
+       };
+
+       print_string(to_roman['9']);    /*FIXME*//* expect: 168 */
+       print_string(to_roman[':']);    /* expect: 168 */
+}
diff -r dda20436a8c6 -r f0ef6c004e1c tests/usr.bin/xlint/lint1/msg_168.exp
--- a/tests/usr.bin/xlint/lint1/msg_168.exp     Sun Mar 07 16:25:06 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_168.exp     Sun Mar 07 16:40:20 2021 +0000
@@ -1,1 +1,3 @@
 msg_168.c(28): warning: array subscript cannot be > 19: 20 [168]
+msg_168.c(40): warning: array subscript cannot be > 2: 57 [168]
+msg_168.c(41): warning: array subscript cannot be > 2: 58 [168]



Home | Main Index | Thread Index | Old Index