Home | History | Annotate | Line # | Download | only in lint1
msg_124.c revision 1.5
      1 /*	$NetBSD: msg_124.c,v 1.5 2021/01/24 11:17:44 rillig Exp $	*/
      2 # 3 "msg_124.c"
      3 
      4 // Test for message: illegal pointer combination, 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);	/*FIXME*//* expect: 274 */
     39 	ok((void *)0 == vp);
     40 	ok((void *)0 == cp);
     41 	ok((void *)0 == ip);
     42 	ok((void *)0 == fp);	/*FIXME*//* expect: 274 */
     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