aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/bswap-constant-folding.c
blob: c6511fe6204108970b8d26104d7f39320256a75e (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
typedef unsigned short __be16;
typedef unsigned short __u16;
typedef unsigned short u16;
#define __force

#define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
/* the test behaves as though it's always on a little-endian machine */
#define __cpu_to_be16(x) ((__force __be16)__swab16((x)))
#define ___htons(x) __cpu_to_be16(x)
#define htons(x) ___htons(x)

#define ETH_P_IPV6 0x86DD

static u16 protocol;

static void test(void)
{
	switch (protocol) {
	case htons(ETH_P_IPV6):
		break;
	}
}

/*
 * check-name: constant folding in bswap builtins
 * check-error-start
 * check-error-end
 */