Module Name: src
Committed By: rillig
Date: Sun Mar 7 16:40:20 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_168.c msg_168.exp
Log Message:
tests/lint: demonstrate wrong warning for array subscript
Seen in usr.bin/indent/lexi.c.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_168.c \
src/tests/usr.bin/xlint/lint1/msg_168.exp
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/msg_168.c
diff -u src/tests/usr.bin/xlint/lint1/msg_168.c:1.2 src/tests/usr.bin/xlint/lint1/msg_168.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_168.c:1.2 Sun Jan 24 16:12:45 2021
+++ src/tests/usr.bin/xlint/lint1/msg_168.c Sun Mar 7 16:40:20 2021
@@ -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 @@ example(void)
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 */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_168.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_168.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_168.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_168.exp:1.2 Sun Jan 24 16:12:45 2021
+++ src/tests/usr.bin/xlint/lint1/msg_168.exp Sun Mar 7 16:40:20 2021
@@ -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]