1230557Sjimharris/*	$NetBSD: expr.c,v 1.1 2024/06/08 09:09:20 rillig Exp $	*/
2230557Sjimharris# 3 "expr.c"
3230557Sjimharris
4230557Sjimharris/*
5230557Sjimharris * Miscellaneous tests for expressions.
6230557Sjimharris */
7230557Sjimharris
8230557Sjimharris/* lint1-extra-flags: -X 351 */
9230557Sjimharris
10230557Sjimharrisstruct bit_fields {
11230557Sjimharris	unsigned u32: 32;
12230557Sjimharris};
13230557Sjimharris
14230557Sjimharrisunsigned long
15230557Sjimharrisexpr_cond_cvt(unsigned long ul)
16230557Sjimharris{
17230557Sjimharris	struct bit_fields bits = { 0 };
18230557Sjimharris	// Combining 'unsigned:32' and 'unsigned long' in the ':' operator
19230557Sjimharris	// results in 'unsigned long'.
20230557Sjimharris	return bits.u32 < ul ? bits.u32 : ul;
21230557Sjimharris}
22230557Sjimharris
23230557Sjimharris// Before tree.c 1.76 from 2014-04-17, lint crashed with an internal error,
24230557Sjimharris// due to an uninitialized right operand of a tree node.
25230557Sjimharrisvoid
26230557Sjimharriscrash_in_assignment(void)
27230557Sjimharris{
28230557Sjimharris	/* expect+1: warning: 'x' set but not used in function 'crash_in_assignment' [191] */
29230557Sjimharris	double x = 1;
30230557Sjimharris	int foo = 0;
31230557Sjimharris	if (foo)
32230557Sjimharris		x = 1;
33230557Sjimharris}
34230557Sjimharris