Skip to content

Commit 7acd4dd

Browse files
committed
[clang][Interp][NFC] Diagnose div by 0 more like the current interpreter
CCEDiag when it's a floating point operation, FFDiag otherwise.
1 parent eb22392 commit 7acd4dd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

clang/lib/AST/Interp/Interp.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,15 @@ template <typename T>
187187
bool CheckDivRem(InterpState &S, CodePtr OpPC, const T &LHS, const T &RHS) {
188188
if (RHS.isZero()) {
189189
const auto *Op = cast<BinaryOperator>(S.Current->getExpr(OpPC));
190+
if constexpr (std::is_same_v<T, Floating>) {
191+
S.CCEDiag(Op, diag::note_expr_divide_by_zero)
192+
<< Op->getRHS()->getSourceRange();
193+
return true;
194+
}
195+
190196
S.FFDiag(Op, diag::note_expr_divide_by_zero)
191197
<< Op->getRHS()->getSourceRange();
192-
if constexpr (!std::is_same_v<T, Floating>)
193-
return false;
198+
return false;
194199
}
195200

196201
if (LHS.isSigned() && LHS.isMin() && RHS.isNegative() && RHS.isMinusOne()) {

0 commit comments

Comments
 (0)