@@ -26,81 +26,6 @@ static_assert(number != 10, ""); // expected-error{{failed}} \
26
26
// expected-note{{evaluates to}} \
27
27
// ref-note{{evaluates to}}
28
28
29
-
30
- #ifdef __SIZEOF_INT128__
31
- namespace i128 {
32
- typedef __int128 int128_t ;
33
- typedef unsigned __int128 uint128_t ;
34
- constexpr int128_t I128_1 = 12 ;
35
- static_assert (I128_1 == 12 , " " );
36
- static_assert (I128_1 != 10 , " " );
37
- static_assert (I128_1 != 12 , " " ); // expected-error{{failed}} \
38
- // ref-error{{failed}} \
39
- // expected-note{{evaluates to}} \
40
- // ref-note{{evaluates to}}
41
-
42
- static const __uint128_t UINT128_MAX =__uint128_t (__int128_t (-1L ));
43
- static_assert (UINT128_MAX == -1 , " " );
44
-
45
- static const __int128_t INT128_MAX = UINT128_MAX >> (__int128_t )1 ;
46
- static_assert (INT128_MAX != 0 , " " );
47
- static const __int128_t INT128_MIN = -INT128_MAX - 1 ;
48
- constexpr __int128 A = INT128_MAX + 1 ; // expected-error {{must be initialized by a constant expression}} \
49
- // expected-note {{outside the range}} \
50
- // ref-error {{must be initialized by a constant expression}} \
51
- // ref-note {{outside the range}}
52
- constexpr int128_t Two = (int128_t )1 << 1ul ;
53
- static_assert (Two == 2 , " " );
54
-
55
- constexpr uint128_t AllOnes = ~static_cast <uint128_t >(0 );
56
- static_assert (AllOnes == UINT128_MAX, " " );
57
-
58
- #if __cplusplus >= 201402L
59
- template <typename T>
60
- constexpr T CastFrom (__int128_t A) {
61
- T B = (T)A;
62
- return B;
63
- }
64
- static_assert (CastFrom<char >(12 ) == 12, "");
65
- static_assert (CastFrom<unsigned char >(12 ) == 12, "");
66
- static_assert (CastFrom<long >(12 ) == 12, "");
67
- static_assert (CastFrom<unsigned short >(12 ) == 12, "");
68
- static_assert (CastFrom<int128_t >(12 ) == 12, "");
69
- static_assert (CastFrom<float >(12 ) == 12, "");
70
- static_assert (CastFrom<double >(12 ) == 12, "");
71
- static_assert (CastFrom<long double >(12 ) == 12, "");
72
-
73
- static_assert (CastFrom<char >(AllOnes) == -1, "");
74
- static_assert (CastFrom<unsigned char >(AllOnes) == 0xFF, "");
75
- static_assert (CastFrom<long >(AllOnes) == -1, "");
76
- static_assert (CastFrom<unsigned short >(AllOnes) == 0xFFFF, "");
77
- static_assert (CastFrom<int >(AllOnes) == -1, "");
78
- static_assert (CastFrom<int128_t >(AllOnes) == -1, "");
79
- static_assert (CastFrom<uint128_t >(AllOnes) == AllOnes, "");
80
-
81
- template <typename T>
82
- constexpr __int128 CastTo (T A) {
83
- int128_t B = (int128_t )A;
84
- return B;
85
- }
86
- static_assert (CastTo<char >(12 ) == 12, "");
87
- static_assert (CastTo<unsigned char >(12 ) == 12, "");
88
- static_assert (CastTo<long >(12 ) == 12, "");
89
- static_assert (CastTo<unsigned long long >(12 ) == 12, "");
90
- static_assert (CastTo<float >(12 ) == 12, "");
91
- static_assert (CastTo<double >(12 ) == 12, "");
92
- static_assert (CastTo<long double >(12 ) == 12, "");
93
- #endif
94
-
95
- constexpr int128_t Error = __LDBL_MAX__; // ref-warning {{implicit conversion of out of range value}} \
96
- // ref-error {{must be initialized by a constant expression}} \
97
- // ref-note {{is outside the range of representable values of type}} \
98
- // expected-warning {{implicit conversion of out of range value}} \
99
- // expected-error {{must be initialized by a constant expression}} \
100
- // expected-note {{is outside the range of representable values of type}}
101
- }
102
- #endif
103
-
104
29
constexpr bool b = number;
105
30
static_assert (b, " " );
106
31
constexpr int one = true ;
0 commit comments