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: add test for constant ...
details: https://anonhg.NetBSD.org/src/rev/57769cafeb9e
branches: trunk
changeset: 981117:57769cafeb9e
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Feb 28 03:29:12 2021 +0000
description:
tests/lint: add test for constant expression involving sizeof
diffstat:
tests/usr.bin/xlint/lint1/msg_161.c | 17 ++++++++++++++++-
tests/usr.bin/xlint/lint1/msg_161.exp | 2 ++
2 files changed, 18 insertions(+), 1 deletions(-)
diffs (37 lines):
diff -r 219c6bf937c7 -r 57769cafeb9e tests/usr.bin/xlint/lint1/msg_161.c
--- a/tests/usr.bin/xlint/lint1/msg_161.c Sun Feb 28 03:14:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_161.c Sun Feb 28 03:29:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_161.c,v 1.4 2021/01/31 12:44:34 rillig Exp $ */
+/* $NetBSD: msg_161.c,v 1.5 2021/02/28 03:29:12 rillig Exp $ */
# 3 "msg_161.c"
// Test for message: constant in conditional context [161]
@@ -40,3 +40,18 @@
} while (1); /* expect: 161 */
}
+
+extern void println(const char *);
+
+void
+test_sizeof(void)
+{
+ /*
+ * XXX: The following conditions should not need CONSTCOND as they
+ * are perfectly legitimate.
+ */
+ if (sizeof(int) > sizeof(char)) /* expect: 161 */
+ println("very probable");
+ if (sizeof(int) < sizeof(char)) /* expect: 161 */
+ println("impossible");
+}
diff -r 219c6bf937c7 -r 57769cafeb9e tests/usr.bin/xlint/lint1/msg_161.exp
--- a/tests/usr.bin/xlint/lint1/msg_161.exp Sun Feb 28 03:14:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_161.exp Sun Feb 28 03:29:12 2021 +0000
@@ -1,3 +1,5 @@
msg_161.c(11): warning: constant in conditional context [161]
msg_161.c(18): warning: constant in conditional context [161]
msg_161.c(41): warning: constant in conditional context [161]
+msg_161.c(53): warning: constant in conditional context [161]
+msg_161.c(55): warning: constant in conditional context [161]
Home |
Main Index |
Thread Index |
Old Index