msg_259.c revision 1.13 1 1.13 rillig /* $NetBSD: msg_259.c,v 1.13 2021/08/30 18:33:37 rillig Exp $ */
2 1.1 rillig # 3 "msg_259.c"
3 1.1 rillig
4 1.6 rillig // Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259]
5 1.1 rillig
6 1.11 rillig /* lint1-only-if: lp64 */
7 1.2 rillig /* lint1-extra-flags: -h */
8 1.2 rillig
9 1.2 rillig void farg_char(char);
10 1.2 rillig void farg_int(int);
11 1.2 rillig void farg_long(long);
12 1.2 rillig
13 1.2 rillig void
14 1.2 rillig example(char c, int i, long l)
15 1.2 rillig {
16 1.2 rillig farg_char(c);
17 1.2 rillig farg_int(c);
18 1.9 rillig /* No warning 259 on LP64, only on ILP32 */
19 1.9 rillig farg_long(c);
20 1.9 rillig
21 1.2 rillig farg_char(i); /* XXX: why no warning? */
22 1.2 rillig farg_int(i);
23 1.9 rillig /* No warning 259 on LP64, only on ILP32 */
24 1.9 rillig farg_long(i);
25 1.9 rillig
26 1.2 rillig farg_char(l); /* XXX: why no warning? */
27 1.9 rillig /* expect+1: from 'long' to 'int' due to prototype [259] */
28 1.9 rillig farg_int(l);
29 1.2 rillig farg_long(l);
30 1.2 rillig }
31 1.10 rillig
32 1.10 rillig void farg_unsigned_int(unsigned int);
33 1.10 rillig void farg_unsigned_long(unsigned long);
34 1.10 rillig void farg_unsigned_long_long(unsigned long long);
35 1.10 rillig
36 1.10 rillig /*
37 1.10 rillig * Converting a signed integer type to its corresponding unsigned integer
38 1.10 rillig * type (C99 6.2.5p6) is usually not a problem. A common case where it
39 1.10 rillig * occurs is when the difference of two pointers is converted to size_t.
40 1.10 rillig */
41 1.10 rillig void
42 1.10 rillig convert_to_corresponding_unsigned(int i, long l, long long ll)
43 1.10 rillig {
44 1.10 rillig /* TODO: don't warn here. */
45 1.10 rillig /* expect+1: warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259] */
46 1.10 rillig farg_unsigned_int(i);
47 1.10 rillig
48 1.10 rillig /* TODO: don't warn here. */
49 1.10 rillig /* expect+1: warning: argument #1 is converted from 'long' to 'unsigned long' due to prototype [259] */
50 1.10 rillig farg_unsigned_long(l);
51 1.10 rillig
52 1.10 rillig /* TODO: don't warn here. */
53 1.10 rillig /* expect+1: warning: argument #1 is converted from 'long long' to 'unsigned long long' due to prototype [259] */
54 1.10 rillig farg_unsigned_long_long(ll);
55 1.12 rillig
56 1.12 rillig /*
57 1.12 rillig * XXX: Why no warning? Even though 'unsigned long' is 64 bits
58 1.12 rillig * wide, it cannot represent negative 32-bit values.
59 1.12 rillig */
60 1.12 rillig farg_unsigned_long(i);
61 1.12 rillig
62 1.12 rillig /*
63 1.12 rillig * XXX: Why no warning? Even though 'unsigned long long' is 64 bits
64 1.12 rillig * wide, it cannot represent negative 32-bit values.
65 1.12 rillig */
66 1.12 rillig farg_unsigned_long_long(i);
67 1.12 rillig
68 1.12 rillig /* expect+1: warning: argument #1 is converted from 'long' to 'unsigned long long' due to prototype [259] */
69 1.12 rillig farg_unsigned_long_long(l);
70 1.10 rillig }
71 1.13 rillig
72 1.13 rillig void
73 1.13 rillig pass_sizeof_as_smaller_type(void)
74 1.13 rillig {
75 1.13 rillig /*
76 1.13 rillig * XXX: Even though the expression has type size_t, it has a constant
77 1.13 rillig * value that fits effortless into an 'unsigned int', it's so small
78 1.13 rillig * that it would even fit into a 3-bit bit-field.
79 1.13 rillig */
80 1.13 rillig /* expect+1: warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259] */
81 1.13 rillig farg_unsigned_int(sizeof(int));
82 1.13 rillig }
83