xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_126.c (revision 567c9b1787dc766f1842a02f2b8bbd8a3314a5bf)
1 /*	$NetBSD: msg_126.c,v 1.9 2024/12/09 22:43:33 rillig Exp $	*/
2 # 3 "msg_126.c"
3 
4 // Test for message: incompatible types '%s' and '%s' in conditional [126]
5 
6 /* lint1-extra-flags: -X 351 -q 1 */
7 
8 /* ARGSUSED */
9 void
10 example(int i, void *ptr, double dbl, void (*return_void)(void))
11 {
12 	/* expect+1: error: incompatible types 'pointer to void' and 'double' in conditional [126] */
13 	i = i > 0 ? ptr : dbl;
14 
15 	ptr = i > 0 ? ptr : (void *)0;
16 
17 	ptr = i > 0 ? ptr : 0;
18 
19 	/* expect+1: implicit conversion from floating point 'double' to integer 'int' [Q1] */
20 	i = i > 0 ? dbl : i;
21 
22 	// GCC accepts the 'int/void' mismatch even with -Wall -Wextra -std=c99.
23 	/* expect+1: warning: incompatible types 'void' and 'int' in conditional [126] */
24 	i > 0 ? return_void() : 0;
25 
26 	i > 0 ? return_void() : (void)0;
27 }
28