From b889b215f61f5a9fd8cd4c2352ed504450df2895 Mon Sep 17 00:00:00 2001 From: rillig Date: Tue, 9 May 2023 15:37:29 +0000 Subject: [PATCH] tests/lint: demonstrate wrong warning about loss of accuracy --- tests/usr.bin/xlint/lint1/msg_132.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/usr.bin/xlint/lint1/msg_132.c b/tests/usr.bin/xlint/lint1/msg_132.c index 0d52d6c37ec7..4c43e086ebb4 100644 --- a/tests/usr.bin/xlint/lint1/msg_132.c +++ b/tests/usr.bin/xlint/lint1/msg_132.c @@ -1,4 +1,4 @@ -/* $NetBSD: msg_132.c,v 1.27 2023/05/09 14:46:36 rillig Exp $ */ +/* $NetBSD: msg_132.c,v 1.28 2023/05/09 15:37:29 rillig Exp $ */ # 3 "msg_132.c" // Test for message: conversion from '%s' to '%s' may lose accuracy [132] @@ -368,6 +368,15 @@ test_ic_bitand(void) u8 = u16 & u32; } +void +test_ic_cvt(void) +{ + u16 = (u32 & 0x0000ff00); + /* FIXME: Don't throw away the constraint. */ + /* expect+1: warning: conversion from 'unsigned int' to 'unsigned short' may lose accuracy [132] */ + u16 = (u32_t)(u32 & 0x0000ff00); +} + void test_ic_conditional(char c1, char c2) {