xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_222.c (revision 53b02e147d4ed531c0d2a5ca9b3e8026ba3e99b5)
1 /*	$NetBSD: msg_222.c,v 1.3 2021/08/27 20:49:25 rillig Exp $	*/
2 # 3 "msg_222.c"
3 
4 // Test for message: conversion of negative constant to unsigned type [222]
5 
6 /* expect+1: warning: initialization of unsigned with negative constant [221] */
7 unsigned int global = -1;
8 
9 void take_unsigned_int(unsigned int);
10 
11 void
12 function(void)
13 {
14 	/* expect+1: warning: initialization of unsigned with negative constant [221] */
15 	unsigned int local = -1;
16 
17 	/* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
18 	take_unsigned_int(-1);
19 
20 	if (local & -1)
21 		return;
22 
23 	/* expect+1: warning: comparison of unsigned int with negative constant, op < [162] */
24 	if (local < -1)
25 		return;
26 
27 	local &= -1;
28 
29 	/* expect+1: warning: conversion of negative constant to unsigned type [222] */
30 	local += -1;
31 }
32