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/f10366138fd8
branches: trunk
changeset: 366542:f10366138fd8
user: rillig <rillig%NetBSD.org@localhost>
date: Mon May 30 08:04:00 2022 +0000
description:
tests/lint: demonstrate wrong warning 'array subscript cannot be'
Since tree.c 1.448 from 2022-05-26.
diffstat:
tests/usr.bin/xlint/lint1/msg_168.c | 27 ++++++++++++++++++++++++++-
tests/usr.bin/xlint/lint1/msg_168.exp | 4 ++++
2 files changed, 30 insertions(+), 1 deletions(-)
diffs (48 lines):
diff -r fb20c67faeb2 -r f10366138fd8 tests/usr.bin/xlint/lint1/msg_168.c
--- a/tests/usr.bin/xlint/lint1/msg_168.c Mon May 30 07:19:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_168.c Mon May 30 08:04:00 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_168.c,v 1.5 2021/03/25 22:53:05 rillig Exp $ */
+/* $NetBSD: msg_168.c,v 1.6 2022/05/30 08:04:00 rillig Exp $ */
# 3 "msg_168.c"
// Test for message: array subscript cannot be > %d: %ld [168]
@@ -40,3 +40,28 @@
print_string(to_roman['9']);
print_string(to_roman[':']); /* expect: 168 */
}
+
+
+struct s {
+ char offset_0;
+ char offset_1;
+ int offset_4;
+ short offset_8;
+ char offset_10;
+};
+
+struct s
+s_init(void)
+{
+ struct s s[1];
+ s->offset_0 = 1;
+ /* expect+1: warning: array subscript cannot be > 0: 1 [168] */
+ s->offset_1 = 2;
+ /* expect+1: warning: array subscript cannot be > 0: 4 [168] */
+ s->offset_4 = 3;
+ /* expect+1: warning: array subscript cannot be > 0: 8 [168] */
+ s->offset_8 = 4;
+ /* expect+1: warning: array subscript cannot be > 0: 10 [168] */
+ s->offset_10 = 5;
+ return s[0];
+}
diff -r fb20c67faeb2 -r f10366138fd8 tests/usr.bin/xlint/lint1/msg_168.exp
--- a/tests/usr.bin/xlint/lint1/msg_168.exp Mon May 30 07:19:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_168.exp Mon May 30 08:04:00 2022 +0000
@@ -1,2 +1,6 @@
msg_168.c(28): warning: array subscript cannot be > 19: 20 [168]
msg_168.c(41): warning: array subscript cannot be > 57: 58 [168]
+msg_168.c(59): warning: array subscript cannot be > 0: 1 [168]
+msg_168.c(61): warning: array subscript cannot be > 0: 4 [168]
+msg_168.c(63): warning: array subscript cannot be > 0: 8 [168]
+msg_168.c(65): warning: array subscript cannot be > 0: 10 [168]
Home |
Main Index |
Thread Index |
Old Index