llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> We need to take signeness into account here. --- Full diff: https://github.com/llvm/llvm-project/pull/145339.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/IntegralAP.h (+10-2) - (modified) clang/test/AST/ByteCode/intap.cpp (+7) ``````````diff diff --git a/clang/lib/AST/ByteCode/IntegralAP.h b/clang/lib/AST/ByteCode/IntegralAP.h index e7499fc9bf5a9..6683db941c736 100644 --- a/clang/lib/AST/ByteCode/IntegralAP.h +++ b/clang/lib/AST/ByteCode/IntegralAP.h @@ -163,8 +163,16 @@ template <bool Signed> class IntegralAP final { return !getValue().isNonNegative(); return false; } - bool isMin() const { return getValue().isMinValue(); } - bool isMax() const { return getValue().isMaxValue(); } + bool isMin() const { + if constexpr (Signed) + return getValue().isMinSignedValue(); + return getValue().isMinValue(); + } + bool isMax() const { + if constexpr (Signed) + return getValue().isMaxSignedValue(); + return getValue().isMaxValue(); + } static constexpr bool isSigned() { return Signed; } bool isMinusOne() const { return Signed && getValue().isAllOnes(); } diff --git a/clang/test/AST/ByteCode/intap.cpp b/clang/test/AST/ByteCode/intap.cpp index 11dd9edb61a94..a7e43b34a7d2b 100644 --- a/clang/test/AST/ByteCode/intap.cpp +++ b/clang/test/AST/ByteCode/intap.cpp @@ -48,6 +48,13 @@ static_assert(DivA / DivB == 2, ""); constexpr _BitInt(4) DivC = DivA / 0; // both-error {{must be initialized by a constant expression}} \ // both-note {{division by zero}} +constexpr __int128 isMinDiv() { + return __int128{0} / __int128{-1}; +} +static_assert(isMinDiv() == 0, ""); + + + constexpr _BitInt(7) RemA = 47; constexpr _BitInt(6) RemB = 9; static_assert(RemA % RemB == 2, ""); `````````` </details> https://github.com/llvm/llvm-project/pull/145339 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits