aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/xlint/lint1/msg_118_ilp32.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/xlint/lint1/msg_118_ilp32.c')
-rw-r--r--usr.bin/xlint/lint1/msg_118_ilp32.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/usr.bin/xlint/lint1/msg_118_ilp32.c b/usr.bin/xlint/lint1/msg_118_ilp32.c
new file mode 100644
index 000000000000..abd78681305b
--- /dev/null
+++ b/usr.bin/xlint/lint1/msg_118_ilp32.c
@@ -0,0 +1,47 @@
+/* $NetBSD: msg_118_ilp32.c,v 1.1 2025/09/06 20:18:41 rillig Exp $ */
+# 3 "msg_118_ilp32.c"
+
+/* Test for message: '%s' %s '%s' differs between traditional C and C90 [118] */
+
+/* lint1-flags: -hw -X 351 */
+/* lint1-only-if: ilp32 */
+
+int si;
+unsigned ui;
+long sl;
+unsigned long ul;
+
+/*
+ * On 32-bit platforms both operands of the '<<' operator are first promoted
+ * individually, and since C90 does not know 'long long', the maximum
+ * bit-size for an integer type is 32 bits.
+ */
+void
+test_shl(void)
+{
+ si <<= si;
+ si <<= ui;
+ si <<= sl;
+ si <<= ul;
+
+ si = si << si;
+ si = si << ui;
+ si = si << sl;
+ si = si << ul;
+}
+
+void
+test_shr(void)
+{
+ si >>= si;
+ si >>= ui;
+ si >>= sl;
+ si >>= ul;
+
+ si = si >> si;
+ /* expect+1: warning: 'int' >> 'unsigned int' differs between traditional C and C90 [118] */
+ si = si >> ui;
+ si = si >> sl;
+ /* expect+1: warning: 'int' >> 'unsigned long' differs between traditional C and C90 [118] */
+ si = si >> ul;
+}