[clang] [clang] Emit bad shift warnings (PR #70307)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 11 06:49:38 PST 2024


================
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wshift-negative-value %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wall %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wshift-negative-value %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wall %s
+
+enum shiftof {
+    X = (-1<<29) //expected-warning {{shifting a negative signed value is undefined}}
----------------
AaronBallman wrote:

```suggestion
    X = (-1<<29) // expected-warning {{shifting a negative signed value is undefined}}
```

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


More information about the cfe-commits mailing list