xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_108.c (revision afab4e300d3a9fb07dd8c80daf53d0feb3345706)
1 /*	$NetBSD: msg_108.c,v 1.8 2023/05/22 12:55:04 rillig Exp $	*/
2 # 3 "msg_108.c"
3 
4 // Test for message: operand of '%s' has invalid type '%s' [108]
5 
6 /*
7  * Before tree.c 1.137 from 2021-01-19, taking the complement of a struct
8  * (an absurd idea, by the way), resulted in an internal error because the
9  * message 108 took two type operands, the second of which was not available
10  * for unary operators.
11  *
12  * Since an error "invalid type 'none'" doesn't make sense, lint rather chose
13  * to crash than to generate such an error.
14  */
15 void
16 complement_of_a_struct(void)
17 {
18 	struct s {
19 		int member;
20 	} s = {
21 	    0
22 	};
23 
24 	/* expect+1: error: operand of '~' has invalid type 'struct s' [108] */
25 	s = ~s;
26 }
27