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

Budimir Aranđelović via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 24 04:20:31 PDT 2024


================
@@ -430,7 +430,8 @@ void dr081(void) {
   /* Demonstrate that we don't crash when left shifting a signed value; that's
    * implementation defined behavior.
    */
- _Static_assert(-1 << 1 == -2, "fail"); /* Didn't shift a zero into the "sign bit". */
+ _Static_assert(-1 << 1 == -2, "fail"); /* c89only-error {{static assertion expression is not an integral constant expression}}
----------------
budimirarandjelovicsyrmia wrote:

This was error in all C language modes. At first, I added diagnosing this error in C mode (file SemaExpr.cpp, lines between 1732-1750, function diagnoseNotICE). After suggestion, I changed it to pedantically emit warning (substitute diagnoseNotICE with diagnoseFold, same part of code).

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


More information about the cfe-commits mailing list