Module Name: src Committed By: rillig Date: Wed Jan 1 14:03:42 UTC 2025
Modified Files: src/tests/usr.bin/xlint/lint1: msg_132.c Log Message: tests/lint: demonstrate wrong warnings for 'char = int + long' To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 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.46 src/tests/usr.bin/xlint/lint1/msg_132.c:1.47 --- src/tests/usr.bin/xlint/lint1/msg_132.c:1.46 Sat Oct 12 09:45:26 2024 +++ src/tests/usr.bin/xlint/lint1/msg_132.c Wed Jan 1 14:03:42 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_132.c,v 1.46 2024/10/12 09:45:26 rillig Exp $ */ +/* $NetBSD: msg_132.c,v 1.47 2025/01/01 14:03:42 rillig Exp $ */ # 3 "msg_132.c" // Test for message: conversion from '%s' to '%s' may lose accuracy [132] @@ -303,6 +303,40 @@ test_ic_mod(void) } void +test_ic_plus(void) +{ + /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */ + s8 = -129 + s64 % 1; + /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */ + s8 = -128 + s64 % 1; + /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */ + s8 = 127 + s64 % 1; + /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */ + s8 = 128 + s64 % 1; + + /* expect+2: warning: conversion of negative constant -129 to unsigned type 'unsigned long long' [222] */ + /* expect+1: warning: conversion from 'unsigned long long' to 'signed char' may lose accuracy [132] */ + s8 = -129 + u64 % 1; + /* expect+2: warning: conversion of negative constant -128 to unsigned type 'unsigned long long' [222] */ + /* expect+1: warning: conversion from 'unsigned long long' to 'signed char' may lose accuracy [132] */ + s8 = -128 + u64 % 1; + /* expect+1: warning: conversion from 'unsigned long long' to 'signed char' may lose accuracy [132] */ + s8 = 127 + u64 % 1; + /* expect+1: warning: conversion from 'unsigned long long' to 'signed char' may lose accuracy [132] */ + s8 = 128 + u64 % 1; + + /* expect+1: warning: conversion from 'unsigned long long' to 'unsigned char' may lose accuracy [132] */ + u8 = 0 + u64 % 1; + /* expect+1: warning: conversion from 'unsigned long long' to 'unsigned char' may lose accuracy [132] */ + u8 = 255 + u64 % 1; + /* expect+1: warning: conversion from 'unsigned long long' to 'unsigned char' may lose accuracy [132] */ + u8 = 256 + u64 % 1; + + /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */ + s8 = '0' + s64 % 10; +} + +void test_ic_shl(void) { u64 = u64 << u64;