[clang] 8f22e43 - [clang][bytecode] Fix multi-word complex division (#181325)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 13 00:45:16 PST 2026
Author: Timm Baeder
Date: 2026-02-13T09:45:11+01:00
New Revision: 8f22e431476698197ddc13d3caa87e7b84254667
URL: https://github.com/llvm/llvm-project/commit/8f22e431476698197ddc13d3caa87e7b84254667
DIFF: https://github.com/llvm/llvm-project/commit/8f22e431476698197ddc13d3caa87e7b84254667.diff
LOG: [clang][bytecode] Fix multi-word complex division (#181325)
Looks like I forgot about `isZero()` when writing this.
Added:
Modified:
clang/lib/AST/ByteCode/Interp.h
clang/test/AST/ByteCode/complex.c
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 1bfa347a9016a..db9514486aa6b 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -481,10 +481,8 @@ inline bool Divc(InterpState &S, CodePtr OpPC) {
const T &RHSR = RHS.elem<T>(0);
const T &RHSI = RHS.elem<T>(1);
unsigned Bits = LHSR.bitWidth();
- const T Zero = T::from(0, Bits);
- if (Compare(RHSR, Zero) == ComparisonCategoryResult::Equal &&
- Compare(RHSI, Zero) == ComparisonCategoryResult::Equal) {
+ if (RHSR.isZero() && RHSI.isZero()) {
const SourceInfo &E = S.Current->getSource(OpPC);
S.FFDiag(E, diag::note_expr_divide_by_zero);
return false;
@@ -507,7 +505,7 @@ inline bool Divc(InterpState &S, CodePtr OpPC) {
if (T::add(A, B, Bits, &Den))
return false;
- if (Compare(Den, Zero) == ComparisonCategoryResult::Equal) {
+ if (Den.isZero()) {
const SourceInfo &E = S.Current->getSource(OpPC);
S.FFDiag(E, diag::note_expr_divide_by_zero);
return false;
diff --git a/clang/test/AST/ByteCode/complex.c b/clang/test/AST/ByteCode/complex.c
index a39f83160ef8c..12c51f95ff7c6 100644
--- a/clang/test/AST/ByteCode/complex.c
+++ b/clang/test/AST/ByteCode/complex.c
@@ -28,3 +28,5 @@ void testComplexFloat(_Atomic(_Complex float) *fp) {
_Complex float f = *fp;
*fp = f;
}
+
+void ZeroNeedsAlloc() { 9999999999999999999wb / 1wbi; } // both-warning 2{{'_BitInt' suffix for literals is a C23 extension}}
More information about the cfe-commits
mailing list