msg_341.c revision 1.3.2.1 1 /* $NetBSD: msg_341.c,v 1.3.2.1 2025/08/02 05:58:18 perseant Exp $ */
2 # 3 "msg_341.c"
3
4 // Test for message: argument to '%s' must be 'unsigned char' or EOF, not '%s' [341]
5
6 /*
7 * Ensure that the functions from <ctype.h> are called with the correct
8 * argument.
9 */
10
11 /* lint1-extra-flags: -X 351 */
12
13 /* NetBSD 9.99.81, <ctype.h> */
14 extern const unsigned short *_ctype_tab_;
15 extern const short *_tolower_tab_;
16 extern const short *_toupper_tab_;
17 int isspace(int);
18
19 void sink(int);
20
21 void
22 function_call_char(char c)
23 {
24
25 /* expect+1: warning: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' [341] */
26 (isspace)(c);
27
28 /* This is the only allowed form. */
29 isspace((unsigned char)c);
30
31 /* The cast to 'int' is redundant, it doesn't hurt though. */
32 isspace((int)(unsigned char)c);
33
34 /* expect+1: warning: argument to 'isspace' must be cast to 'unsigned char', not to 'int' [342] */
35 isspace((int)c);
36
37 /* expect+1: warning: argument to 'isspace' must be cast to 'unsigned char', not to 'unsigned int' [342] */
38 isspace((unsigned int)c);
39 }
40
41 /*
42 * If the expression starts with type 'unsigned char', it can be cast to any
43 * other type. Chances are low enough that the cast is to 'char', which would
44 * be the only bad type.
45 */
46 void
47 function_call_unsigned_char(unsigned char c)
48 {
49
50 (isspace)(c);
51 isspace((unsigned char)c);
52 isspace((int)c);
53 isspace((unsigned int)c);
54 }
55
56 /* When used in a loop of fgetc, the type is already 'int'. That's fine. */
57 void
58 function_call_int(int c)
59 {
60
61 isspace(c);
62 }
63
64 void
65 macro_invocation_NetBSD(char c, signed char sc)
66 {
67
68 /* expect+1: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'char' [341] */
69 sink(((int)((_ctype_tab_ + 1)[(c)] & 0x0040)));
70
71 /* This is the only allowed form. */
72 sink(((int)((_ctype_tab_ + 1)[((unsigned char)c)] & 0x0040)));
73
74 /* expect+1: warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'int' [342] */
75 sink(((int)((_ctype_tab_ + 1)[((int)c)] & 0x0040)));
76
77 /* expect+1: warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'unsigned int' [342] */
78 sink(((int)((_ctype_tab_ + 1)[((unsigned int)c)] & 0x0040)));
79
80 // See platform_ilp32_int.c.
81 // See platform_ilp32_long.c.
82 // See platform_lp64.c.
83
84 /* expect+1: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'signed char' [341] */
85 sink(((int)((_ctype_tab_ + 1)[sc])));
86 }
87