[clang] [clang] Fix shift-count diagnostics for compound assignments (PR #234830)
Chen Miao via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 30 03:05:25 PDT 2026
================
@@ -71,6 +74,41 @@ void test_shift_too_much(char x) {
(void) (x >> 80); // expected-warning {{shift count >= width of type}}
}
+// For compound shift assignments, check the shift count against the width of
+// the promoted LHS, just like regular shift assignments.
+// https://github.com/llvm/llvm-project/issues/234217
+unsigned char char_compound(unsigned char x) {
+ x >>= 8;
+ return x;
+}
+
+unsigned char char_ordinary(unsigned char x) {
+ x = x >> 8;
+ return x;
+}
+
+unsigned short short_compound(unsigned short x) {
+ x >>= 16;
+ return x;
+}
+
+unsigned short short_ordinary(unsigned short x) {
----------------
ChenMiaoi wrote:
Same
https://github.com/llvm/llvm-project/pull/234830
More information about the cfe-commits
mailing list