msg_222.c revision 1.7 1 /* $NetBSD: msg_222.c,v 1.7 2024/12/15 05:56:18 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(signed char *scp, unsigned char *ucp)
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 *scp += 'A' - 'a';
35 *scp -= 'A' - 'a';
36
37 // XXX: It's perfectly fine to effectively subtract a constant from
38 // XXX: an unsigned type.
39 /* expect+1: warning: conversion of negative constant -32 to unsigned type 'unsigned char' [222] */
40 *ucp += 'A' - 'a';
41 /* expect+1: warning: conversion of negative constant -32 to unsigned type 'unsigned char' [222] */
42 *ucp -= 'A' - 'a';
43 }
44