aboutsummaryrefslogtreecommitdiff
path: root/test/enum-fixed.c
blob: 9ac85ca2ad14fd18d2534b46f81f482050ccef7e (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
33
34
35
36
enum E1 : short;
_Static_assert(__builtin_types_compatible_p(enum E1, short));

enum E2 : unsigned short {
	A2 = 0x7fff,
	B2,
	A2type = __builtin_types_compatible_p(typeof(A2), unsigned short),
	B2type = __builtin_types_compatible_p(typeof(B2), unsigned short),
};
_Static_assert(__builtin_types_compatible_p(typeof(A2), unsigned short));
_Static_assert(A2type == 1);
_Static_assert(__builtin_types_compatible_p(typeof(B2), unsigned short));
_Static_assert(B2type == 1);
_Static_assert(__builtin_types_compatible_p(enum E2, unsigned short));

enum E3 : long long {
	A3,
	B3,
	A3type = __builtin_types_compatible_p(typeof(A3), long long),
	B3type = __builtin_types_compatible_p(typeof(B3), long long),
};
_Static_assert(__builtin_types_compatible_p(typeof(A3), long long));
_Static_assert(A3type == 1);
_Static_assert(__builtin_types_compatible_p(typeof(B3), long long));
_Static_assert(B3type == 1);
_Static_assert(__builtin_types_compatible_p(enum E3, long long));

enum E4 : long long {
	A4 = sizeof(enum E4),
	A4type1 = __builtin_types_compatible_p(typeof(A4), enum E4),
	A4type2 = !__builtin_types_compatible_p(typeof(A4), enum E3),
};
_Static_assert(__builtin_types_compatible_p(typeof(A4), enum E4));
_Static_assert(A4type1 == 1);
_Static_assert(!__builtin_types_compatible_p(typeof(A4), enum E3));
_Static_assert(A4type2 == 1);