xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_123.c (revision 7d62b00eb9ad855ffcd7da46b41e23feb5476fac)
1 /*	$NetBSD: msg_123.c,v 1.6 2022/06/19 12:14:34 rillig Exp $	*/
2 # 3 "msg_123.c"
3 
4 // Test for message: illegal combination of %s '%s' and %s '%s', op '%s' [123]
5 
6 void ok(_Bool);
7 void bad(_Bool);
8 
9 void
10 compare(_Bool b, int i, double d, const char *p)
11 {
12 	ok(b < b);
13 	ok(b < i);
14 	ok(b < d);
15 	/* expect+1: warning: illegal combination of integer '_Bool' and pointer 'pointer to const char', op '<' [123] */
16 	bad(b < p);
17 	ok(i < b);
18 	ok(i < i);
19 	ok(i < d);
20 	/* expect+1: warning: illegal combination of integer 'int' and pointer 'pointer to const char', op '<' [123] */
21 	bad(i < p);
22 	ok(d < b);
23 	ok(d < i);
24 	ok(d < d);
25 	/* expect+1: error: operands of '<' have incompatible types 'double' and 'pointer' [107] */
26 	bad(d < p);
27 	/* expect+1: warning: illegal combination of pointer 'pointer to const char' and integer '_Bool', op '<' [123] */
28 	bad(p < b);
29 	/* expect+1: warning: illegal combination of pointer 'pointer to const char' and integer 'int', op '<' [123] */
30 	bad(p < i);
31 	/* expect+1: error: operands of '<' have incompatible types 'pointer' and 'double' [107] */
32 	bad(p < d);
33 	ok(p < p);
34 }
35 
36 void
37 cover_check_assign_types_compatible(int *int_pointer, int i)
38 {
39 	/* expect+1: warning: illegal combination of pointer 'pointer to int' and integer 'int', op '=' [123] */
40 	int_pointer = i;
41 	/* expect+1: warning: illegal combination of integer 'int' and pointer 'pointer to int', op '=' [123] */
42 	i = int_pointer;
43 }
44