summaryrefslogtreecommitdiff
path: root/tests/usr.bin/xlint/lint1/msg_306.c
blob: 473d4ec25a5a37c88a376ebf055264caac181a4c (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
29
30
31
32
/*	$NetBSD: msg_306.c,v 1.5 2023/07/07 19:45:22 rillig Exp $	*/
# 3 "msg_306.c"

// Test for message: constant truncated by conversion, op '%s' [306]

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

unsigned char
to_u8(void)
{
	/* expect+1: warning: conversion of 'int' to 'unsigned char' is out of range [119] */
	return 12345;
}

unsigned char
and_u8(unsigned char a)
{
	/* XXX: unused bits in constant */
	return a & 0x1234;
}

unsigned char
or_u8(unsigned char a)
{
	/* expect+1: warning: constant truncated by conversion, op '|=' [306] */
	a |= 0x1234;

	/* XXX: Lint doesn't care about the expanded form of the same code. */
	a = a | 0x1234;

	return a;
}