xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_245.c (revision 7d62b00eb9ad855ffcd7da46b41e23feb5476fac)
1 /*	$NetBSD: msg_245.c,v 1.5 2022/06/16 21:24:41 rillig Exp $	*/
2 # 3 "msg_245.c"
3 
4 // Test for message: incompatible structure pointers: '%s' '%s' '%s' [245]
5 
6 typedef struct tag_and_typedef_tag {
7 	int member;
8 } tag_and_typedef_typedef;
9 
10 struct only_tag {
11 	int member;
12 };
13 
14 typedef struct {
15 	int member;
16 } only_typedef;
17 
18 struct {
19 	int member;
20 } unnamed;
21 
22 void sink_bool(_Bool);
23 
24 void
25 example(tag_and_typedef_typedef both,
26 	only_typedef only_typedef,
27 	struct only_tag only_tag)
28 {
29 	/* expect+1: warning: incompatible structure pointers: 'pointer to struct tag_and_typedef_tag' '==' 'pointer to struct only_tag' [245] */
30 	sink_bool(&both == &only_tag);
31 	/* expect+1: warning: incompatible structure pointers: 'pointer to struct tag_and_typedef_tag' '==' 'pointer to struct typedef only_typedef' [245] */
32 	sink_bool(&both == &only_typedef);
33 	/* expect+1: warning: incompatible structure pointers: 'pointer to struct tag_and_typedef_tag' '==' 'pointer to struct <unnamed>' [245] */
34 	sink_bool(&both == &unnamed);
35 }
36