1 /* $NetBSD: msg_123.c,v 1.8 2023/06/03 20:28:54 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 /* lint1-extra-flags: -X 351 */
7
8 void ok(_Bool);
9 void bad(_Bool);
10
11 void
compare(_Bool b,int i,double d,const char * p)12 compare(_Bool b, int i, double d, const char *p)
13 {
14 ok(b < b);
15 ok(b < i);
16 ok(b < d);
17 /* expect+1: warning: illegal combination of integer '_Bool' and pointer 'pointer to const char', op '<' [123] */
18 bad(b < p);
19 ok(i < b);
20 ok(i < i);
21 ok(i < d);
22 /* expect+1: warning: illegal combination of integer 'int' and pointer 'pointer to const char', op '<' [123] */
23 bad(i < p);
24 ok(d < b);
25 ok(d < i);
26 ok(d < d);
27 /* expect+1: error: operands of '<' have incompatible types 'double' and 'pointer to const char' [107] */
28 bad(d < p);
29 /* expect+1: warning: illegal combination of pointer 'pointer to const char' and integer '_Bool', op '<' [123] */
30 bad(p < b);
31 /* expect+1: warning: illegal combination of pointer 'pointer to const char' and integer 'int', op '<' [123] */
32 bad(p < i);
33 /* expect+1: error: operands of '<' have incompatible types 'pointer to const char' and 'double' [107] */
34 bad(p < d);
35 ok(p < p);
36 }
37
38 void
cover_check_assign_types_compatible(int * int_pointer,int i)39 cover_check_assign_types_compatible(int *int_pointer, int i)
40 {
41 /* expect+1: warning: illegal combination of pointer 'pointer to int' and integer 'int', op '=' [123] */
42 int_pointer = i;
43 /* expect+1: warning: illegal combination of integer 'int' and pointer 'pointer to int', op '=' [123] */
44 i = int_pointer;
45 }
46