aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/constexpr-pure-builtin.c
blob: f4cd67edae3003aee6da8b029bcaea4f58730f3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// requires constant integer expressions
static int bar[] = {
	[__builtin_bswap16(0x1234)] = 0,		// OK
	[__builtin_bswap32(0x1234)] = 0,		// OK
	[__builtin_bswap64(0x1234)] = 0,		// OK
};

// requires constant integers
static int foo(unsigned long long a)
{
	switch (a) {
	case __builtin_bswap16(1   <<  8):
	case __builtin_bswap32(2L  << 24):
	case __builtin_bswap64(3LL << 56):
		return 0;
	default:
		return 1;
	}
}

/*
 * check-name: constness of pure/const builtins
 */