[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) {
----------------
ChenMiaoi wrote:

Your change shouldn’t affect the ordinary case. Do we need this test?

https://github.com/llvm/llvm-project/pull/234830


More information about the cfe-commits mailing list