Module Name:    src
Committed By:   rillig
Date:           Mon Mar 25 22:46:23 UTC 2024

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_132.c

Log Message:
tests/lint: demonstrate wrong warnings about lossy bit field operations


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/tests/usr.bin/xlint/lint1/msg_132.c

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_132.c
diff -u src/tests/usr.bin/xlint/lint1/msg_132.c:1.36 src/tests/usr.bin/xlint/lint1/msg_132.c:1.37
--- src/tests/usr.bin/xlint/lint1/msg_132.c:1.36	Tue Mar 12 20:35:29 2024
+++ src/tests/usr.bin/xlint/lint1/msg_132.c	Mon Mar 25 22:46:23 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_132.c,v 1.36 2024/03/12 20:35:29 rillig Exp $	*/
+/*	$NetBSD: msg_132.c,v 1.37 2024/03/25 22:46:23 rillig Exp $	*/
 # 3 "msg_132.c"
 
 // Test for message: conversion from '%s' to '%s' may lose accuracy [132]
@@ -427,3 +427,20 @@ compare_bit_field_to_integer_constant(vo
 	b = s.u64 == 0;
 	b = !b;
 }
+
+_Bool
+binary_operators_on_bit_fields(void)
+{
+	struct {
+		unsigned long long u15:15;
+		unsigned long long u48:48;
+		unsigned long long u64;
+	} s = { 0, 0, 0 };
+
+	u64 = s.u15 | s.u48;
+	/* expect+1: warning: conversion from 'unsigned long long:16' to 'int:17' may lose accuracy [132] */
+	u64 = s.u15 | s.u48 | s.u64;
+	/* expect+2: warning: conversion from 'unsigned long long:16' to 'int:17' may lose accuracy [132] */
+	/* expect+1: warning: conversion from 'unsigned long long:17' to 'int:18' may lose accuracy [132] */
+	return (s.u15 | s.u48 | s.u64) != 0;
+}

Reply via email to