Home | History | Annotate | Line # | Download | only in lint1
msg_124.c revision 1.12
      1 /*	$NetBSD: msg_124.c,v 1.12 2022/06/16 16:58:36 rillig Exp $	*/
      2 # 3 "msg_124.c"
      3 
      4 // Test for message: illegal combination of '%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 	/* expect+1: warning: illegal combination of 'pointer to function(int) returning void' and 'pointer to int', op 'init' [124] */
     19 	signal_handler handler = ptr;
     20 	/* expect+1: warning: illegal combination of 'pointer to function(pointer to function(int) returning void) returning pointer to function(int) returning void' and 'pointer to int', op 'init' [124] */
     21 	sys_signal signal = ptr;
     22 	/* expect+1: warning: illegal combination of 'pointer to function(pointer to const char, ...) returning int' and 'pointer to int', op 'init' [124] */
     23 	printflike printf = ptr;
     24 }
     25 
     26 void ok(_Bool);
     27 void not_ok(_Bool);
     28 
     29 void
     30 compare_pointers(const void *vp, const char *cp, const int *ip,
     31 		 signal_handler fp)
     32 {
     33 	ok(vp == cp);
     34 	ok(vp == ip);
     35 	/* expect+1: warning: ANSI C forbids comparison of 'void *' with function pointer [274] */
     36 	ok(vp == fp);
     37 	/* expect+1: warning: illegal combination of 'pointer to const char' and 'pointer to const int', op '==' [124] */
     38 	not_ok(cp == ip);
     39 	/* expect+1: warning: illegal combination of 'pointer to const char' and 'pointer to function(int) returning void', op '==' [124] */
     40 	not_ok(cp == fp);
     41 	ok(vp == (void *)0);
     42 	ok(cp == (void *)0);
     43 	ok(ip == (void *)0);
     44 	ok(fp == (void *)0);	/* wrong 274 before 2021-01-25 */
     45 	ok((void *)0 == vp);
     46 	ok((void *)0 == cp);
     47 	ok((void *)0 == ip);
     48 	ok((void *)0 == fp);	/* wrong 274 before 2021-01-25 */
     49 	ok(vp == 0);
     50 	ok(cp == 0);
     51 	ok(ip == 0);
     52 	ok(fp == 0);
     53 	ok(vp == 0L);
     54 	ok(cp == 0L);
     55 	ok(ip == 0L);
     56 	ok(fp == 0L);
     57 }
     58