File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -140,9 +140,8 @@ template <bool Signed> class IntegralAP final {
140
140
return NameStr;
141
141
}
142
142
143
- IntegralAP truncate (unsigned bitWidth) const {
144
- assert (false );
145
- return V;
143
+ IntegralAP truncate (unsigned BitWidth) const {
144
+ return IntegralAP (V.trunc (BitWidth));
146
145
}
147
146
148
147
IntegralAP<false > toUnsigned () const {
Original file line number Diff line number Diff line change @@ -121,4 +121,20 @@ namespace AddSubOffset {
121
121
static_assert (*P2 == 1 ," " );
122
122
}
123
123
124
+ namespace Bitfields {
125
+ struct S1 {
126
+ unsigned _BitInt (128 ) a : 2;
127
+ };
128
+ constexpr S1 s1{100 }; // ref-warning {{changes value from 100 to 0}} \
129
+ // expected-warning {{changes value from 100 to 0}}
130
+ constexpr S1 s12{3 };
131
+ static_assert (s12.a == 3 , " " );
132
+
133
+ struct S2 {
134
+ unsigned __int128 a : 2 ;
135
+ };
136
+ constexpr S2 s2{100 }; // ref-warning {{changes value from 100 to 0}} \
137
+ // expected-warning {{changes value from 100 to 0}}
138
+ }
139
+
124
140
#endif
You can’t perform that action at this time.
0 commit comments