[clang] [clang][Interp] Implement IntegralAP::{div, rem} (PR #72614)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 8 08:49:30 PST 2023


================
@@ -44,6 +44,24 @@ static_assert(MulA * MulB == 50, ""); // ref-error {{not an integral constant ex
 static_assert(MulA * 5 == 25, "");
 static_assert(-1 * MulB == -7, "");
 
+
+constexpr _BitInt(4) DivA = 2;
+constexpr _BitInt(2) DivB = 1;
+static_assert(DivA / DivB == 2, "");
+
+constexpr _BitInt(4) DivC = DivA / 0; // ref-error {{must be initialized by a constant expression}} \
----------------
AaronBallman wrote:

I'd appreciate another test along the lines of:
```
constexpr int bottom = -1;
constexpr int top = INT_MIN;
constexpr int nope = top / bottom;
constexpr int noooo = top % bottom;
```

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


More information about the cfe-commits mailing list