xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_222.c (revision ccd9df534e375a4366c5b55f23782053c7a98d82)
1 /*	$NetBSD: msg_222.c,v 1.6 2024/06/08 06:37:06 rillig Exp $	*/
2 # 3 "msg_222.c"
3 
4 // Test for message: conversion of negative constant %lld to unsigned type '%s' [222]
5 
6 /* lint1-extra-flags: -X 351 */
7 
8 /* expect+1: warning: initialization of unsigned type 'unsigned int' with negative constant -1 [221] */
9 unsigned int global = -1;
10 
11 void take_unsigned_int(unsigned int);
12 
13 void
14 function(void)
15 {
16 	/* expect+1: warning: initialization of unsigned type 'unsigned int' with negative constant -1 [221] */
17 	unsigned int local = -1;
18 
19 	/* expect+1: warning: conversion of negative constant -1 to unsigned type 'unsigned int', arg #1 [296] */
20 	take_unsigned_int(-1);
21 
22 	if (local & -1)
23 		return;
24 
25 	/* expect+1: warning: operator '<' compares 'unsigned int' with 'negative constant' [162] */
26 	if (local < -1)
27 		return;
28 
29 	local &= -1;
30 
31 	/* expect+1: warning: conversion of negative constant -1 to unsigned type 'unsigned int' [222] */
32 	local += -1;
33 }
34