summaryrefslogtreecommitdiff
path: root/tests/usr.bin/xlint/lint1/msg_108.c
blob: 065d63e47c1940753d01c3d4ad12940234c4c9e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*	$NetBSD: msg_108.c,v 1.9 2023/07/07 19:45:22 rillig Exp $	*/
# 3 "msg_108.c"

// Test for message: operand of '%s' has invalid type '%s' [108]

/* lint1-extra-flags: -X 351 */

/*
 * Before tree.c 1.137 from 2021-01-19, taking the complement of a struct
 * (an absurd idea, by the way), resulted in an internal error because the
 * message 108 took two type operands, the second of which was not available
 * for unary operators.
 *
 * Since an error "invalid type 'none'" doesn't make sense, lint rather chose
 * to crash than to generate such an error.
 */
void
complement_of_a_struct(void)
{
	struct s {
		int member;
	} s = {
	    0
	};

	/* expect+1: error: operand of '~' has invalid type 'struct s' [108] */
	s = ~s;
}