xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_124.c (revision 82d56013d7b633d116a93943de88e08335357a7c)
1 /*	$NetBSD: msg_124.c,v 1.9 2021/04/13 22:21:19 christos Exp $	*/
2 # 3 "msg_124.c"
3 
4 // Test for message: illegal pointer combination (%s) and (%s), op %s [124]
5 
6 /* lint1-extra-flags: -s */
7 
8 typedef void(*signal_handler)(int);
9 
10 typedef signal_handler(*sys_signal)(signal_handler);
11 
12 typedef int(*printflike)(const char *, ...)
13     __attribute__((format(printf, 1, 2)));
14 
15 void
16 example(int *ptr)
17 {
18 	signal_handler handler = ptr;	/* expect: 124 */
19 	sys_signal signal = ptr;	/* expect: 124 */
20 	printflike printf = ptr;	/* expect: 124 */
21 }
22 
23 void ok(_Bool);
24 void not_ok(_Bool);
25 
26 void
27 compare_pointers(const void *vp, const char *cp, const int *ip,
28 		 signal_handler fp)
29 {
30 	ok(vp == cp);
31 	ok(vp == ip);
32 	ok(vp == fp);		/* expect: 274 */
33 	not_ok(cp == ip);	/* expect: 124 */
34 	not_ok(cp == fp);	/* expect: 124 */
35 	ok(vp == (void *)0);
36 	ok(cp == (void *)0);
37 	ok(ip == (void *)0);
38 	ok(fp == (void *)0);	/* wrong 274 before 2021-01-25 */
39 	ok((void *)0 == vp);
40 	ok((void *)0 == cp);
41 	ok((void *)0 == ip);
42 	ok((void *)0 == fp);	/* wrong 274 before 2021-01-25 */
43 	ok(vp == 0);
44 	ok(cp == 0);
45 	ok(ip == 0);
46 	ok(fp == 0);
47 	ok(vp == 0L);
48 	ok(cp == 0L);
49 	ok(ip == 0L);
50 	ok(fp == 0L);
51 }
52 
53 void	test_varargs_attribute(void (*pr)(const char *, ...) __attribute__((__format__(__printf__, 1, 2))));
54 
55