https://github.com/superdusty updated 
https://github.com/llvm/llvm-project/pull/199912

>From 8b793c0202da13b640bb22a7b3fb3d0646690714 Mon Sep 17 00:00:00 2001
From: cry <[email protected]>
Date: Thu, 28 May 2026 12:57:42 +0800
Subject: [PATCH 1/2] [Clang] Fix crash when comparing fixed point type with
 BitInt

---
 clang/docs/ReleaseNotes.rst          | 1 +
 clang/lib/Sema/SemaExpr.cpp          | 5 ++++-
 clang/test/Sema/fixed-point-bitint.c | 8 ++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Sema/fixed-point-bitint.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6838cf3defcc1..f8c421824cb7b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -559,6 +559,7 @@ Improvements to Coverage Mapping
 Bug Fixes in This Version
 -------------------------
 
+- Fixed a crash when comparing a fixed point type with a ``_BitInt`` type. 
(#GH196948)
 - Fixed atomic boolean compound assignment; the conversion back to atomic bool 
would be miscompiled. (#GH33210)
 - Correctly handle default template argument when establishing subsumption. 
(#GH188640)
 - Fixed a failed assertion in the preprocessor when ``__has_embed`` parameters 
are missing parentheses. (#GH175088)
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 521a8516ac179..d88e34fcc43fc 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1287,6 +1287,10 @@ static QualType handleFloatConversion(Sema &S, 
ExprResult &LHS,
 /// Helper function of UsualArithmeticConversions().
 static bool unsupportedTypeConversion(const Sema &S, QualType LHSType,
                                       QualType RHSType) {
+  if ((LHSType->isFixedPointType() && RHSType->isBitIntType()) ||
+      (LHSType->isBitIntType() && RHSType->isFixedPointType()))
+    return true;
+
   // No issue if either is not a floating point type.
   if (!LHSType->isFloatingType() || !RHSType->isFloatingType())
     return false;
@@ -1533,7 +1537,6 @@ static QualType handleFixedPointConversion(Sema &S, 
QualType LHSTy,
           RHSTy->isFixedPointOrIntegerType()) &&
          "Special fixed point arithmetic operation conversions are only "
          "applied to ints or other fixed point types");
-
   // If one operand has signed fixed-point type and the other operand has
   // unsigned fixed-point type, then the unsigned fixed-point operand is
   // converted to its corresponding signed fixed-point type and the resulting
diff --git a/clang/test/Sema/fixed-point-bitint.c 
b/clang/test/Sema/fixed-point-bitint.c
new file mode 100644
index 0000000000000..d9ebf9fd61dbe
--- /dev/null
+++ b/clang/test/Sema/fixed-point-bitint.c
@@ -0,0 +1,8 @@
+// RUN: %%clang_cc1 -ffixed-point -fsyntax-only -verify %%s 
+ 
+// Test that comparing fixed point type with BitInt doesn't crash 
+// Fixes issue #196948 
+ 
+constexpr _BitInt(128) i = 42; 
+static_assert(i == 42.0k); 
+// expected-error@-1 {{invalid operands to binary expression}} 

>From 01d90659ecaf45aaad6758756c0a205135b3f4e3 Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 13:35:27 +0800
Subject: [PATCH 2/2] Update fixed-point-bitint.c

---
 clang/test/Sema/fixed-point-bitint.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/test/Sema/fixed-point-bitint.c 
b/clang/test/Sema/fixed-point-bitint.c
index d9ebf9fd61dbe..78f7cb787d571 100644
--- a/clang/test/Sema/fixed-point-bitint.c
+++ b/clang/test/Sema/fixed-point-bitint.c
@@ -1,8 +1,5 @@
 // RUN: %%clang_cc1 -ffixed-point -fsyntax-only -verify %%s 
  
-// Test that comparing fixed point type with BitInt doesn't crash 
-// Fixes issue #196948 
- 
 constexpr _BitInt(128) i = 42; 
 static_assert(i == 42.0k); 
 // expected-error@-1 {{invalid operands to binary expression}} 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to