Module Name: src
Committed By: rillig
Date: Sun Feb 28 03:29:12 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_161.c msg_161.exp
Log Message:
tests/lint: add test for constant expression involving sizeof
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_161.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_161.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_161.c
diff -u src/tests/usr.bin/xlint/lint1/msg_161.c:1.4 src/tests/usr.bin/xlint/lint1/msg_161.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_161.c:1.4 Sun Jan 31 12:44:34 2021
+++ src/tests/usr.bin/xlint/lint1/msg_161.c Sun Feb 28 03:29:12 2021
@@ -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 @@ do_while_1(void)
} 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");
+}
Index: src/tests/usr.bin/xlint/lint1/msg_161.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_161.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_161.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_161.exp:1.3 Sun Jan 31 12:44:34 2021
+++ src/tests/usr.bin/xlint/lint1/msg_161.exp Sun Feb 28 03:29:12 2021
@@ -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]