[PATCH] D150209: [clang][Interp] Add more shift error checking

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 9 16:35:15 PDT 2023


shafik added inline comments.


================
Comment at: clang/lib/AST/Interp/Interp.h:133
+    // operand, and must not overflow the corresponding unsigned type.
+    // C++2a [expr.shift]p2: E1 << E2 is the unique value congruent to
+    // E1 x 2^E2 module 2^N.
----------------
Maybe this quote for C++20 should be moved below the else block with a comment noting that C++20 forward the above is no longer UB? My first reading I thought the second quote applied to the `else if` below and was super confused.


================
Comment at: clang/lib/AST/Interp/Interp.h:136
+    if (LHS.isNegative())
+      S.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << 12;
+    else if (LHS.toUnsigned().countLeadingZeros() < static_cast<unsigned>(RHS))
----------------
Do we test this diagnostic?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150209/new/

https://reviews.llvm.org/D150209



More information about the cfe-commits mailing list