File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -119,8 +119,16 @@ template <bool Signed> class IntegralAP final {
119
119
120
120
constexpr unsigned bitWidth () const { return V.getBitWidth (); }
121
121
122
- APSInt toAPSInt (unsigned Bits = 0 ) const { return APSInt (V, !Signed); }
123
- APValue toAPValue () const { return APValue (APSInt (V, !Signed)); }
122
+ APSInt toAPSInt (unsigned Bits = 0 ) const {
123
+ if (Bits == 0 )
124
+ Bits = bitWidth ();
125
+
126
+ if constexpr (Signed)
127
+ return APSInt (V.sext (Bits), !Signed);
128
+ else
129
+ return APSInt (V.zext (Bits), !Signed);
130
+ }
131
+ APValue toAPValue () const { return APValue (toAPSInt ()); }
124
132
125
133
bool isZero () const { return V.isZero (); }
126
134
bool isPositive () const { return V.isNonNegative (); }
Original file line number Diff line number Diff line change @@ -63,11 +63,16 @@ namespace i128 {
63
63
64
64
static const __int128_t INT128_MAX = UINT128_MAX >> (__int128_t )1 ;
65
65
static_assert (INT128_MAX != 0 , " " );
66
+ static_assert (INT128_MAX == 0 , " " ); // expected-error {{failed}} \
67
+ // expected-note {{evaluates to '170141183460469231731687303715884105727 == 0'}} \
68
+ // ref-error {{failed}} \
69
+ // ref-note {{evaluates to '170141183460469231731687303715884105727 == 0'}}
70
+
66
71
static const __int128_t INT128_MIN = -INT128_MAX - 1 ;
67
72
constexpr __int128 A = INT128_MAX + 1 ; // expected-error {{must be initialized by a constant expression}} \
68
- // expected-note {{outside the range}} \
73
+ // expected-note {{value 170141183460469231731687303715884105728 is outside the range}} \
69
74
// ref-error {{must be initialized by a constant expression}} \
70
- // ref-note {{outside the range}}
75
+ // ref-note {{value 170141183460469231731687303715884105728 is outside the range}}
71
76
constexpr int128_t Two = (int128_t )1 << 1ul ;
72
77
static_assert (Two == 2 , " " );
73
78
static_assert (Two, " " );
You can’t perform that action at this time.
0 commit comments