msg_192.c revision 1.10 1 /* $NetBSD: msg_192.c,v 1.10 2024/09/26 21:31:09 rillig Exp $ */
2 # 3 "msg_192.c"
3
4 // Test for message: '%s' unused in function '%s' [192]
5 //
6 // See also:
7 // msg_231 for unused parameters
8
9 /* lint1-extra-flags: -X 351 */
10
11 void
12 example(void)
13 {
14 /* expect+1: warning: 'local_scalar' unused in function 'example' [192] */
15 int local_scalar;
16 /* expect+1: warning: 'local_ptr' unused in function 'example' [192] */
17 char *local_ptr;
18 /* expect+1: warning: 'local_arr' unused in function 'example' [192] */
19 char local_arr[5];
20 /* expect+1: warning: 'local_func' unused in function 'example' [192] */
21 void (*local_func)(int, double);
22 typedef void (*handler)(int);
23 /* expect+1: warning: 'local_signal' unused in function 'example' [192] */
24 handler (*local_signal)(int, handler);
25 }
26
27
28 void assertion_failed(const char *, int, const char *, const char *);
29
30 /*
31 * The symbol '__func__' only occurs in an unreachable branch. It is
32 * nevertheless marked as used.
33 */
34 void
35 assert_true(void)
36 {
37 sizeof(char) == 1
38 ? (void)0
39 : assertion_failed("file", 26, __func__, "sizeof(char) == 1");
40 }
41
42 void
43 assert_false(void)
44 {
45 sizeof(char) == 0
46 ? (void)0
47 : assertion_failed("file", 34, __func__, "sizeof(char) == 0");
48 }
49
50 void
51 assert_unknown(_Bool cond)
52 {
53 cond
54 ? (void)0
55 : assertion_failed("file", 42, __func__, "cond");
56 }
57