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 01/14] [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 02/14] 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}} 

>From 6410f56d63a0aad05e46592e046ea848ae5c89d0 Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 13:38:16 +0800
Subject: [PATCH 03/14] Update ReleaseNotes.rst

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f8c421824cb7b..bf44a2a4e3d11 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -559,7 +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 an assertion 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)

>From f1d0967f0b7a3f27749806ac1fadb3a20a26e534 Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 13:42:13 +0800
Subject: [PATCH 04/14] Update SemaExpr.cpp

---
 clang/lib/Sema/SemaExpr.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d88e34fcc43fc..e6bad816d2d0a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1285,6 +1285,9 @@ static QualType handleFloatConversion(Sema &S, ExprResult 
&LHS,
 /// Diagnose attempts to convert between __float128, __ibm128 and
 /// long double if there is no support for such conversion.
 /// Helper function of UsualArithmeticConversions().
+/// Returns true if the conversion between LHSType and RHSType is not 
supported.
+/// This includes conversions between fixed point types and BitInt types,
+/// which would otherwise cause an assertion failure later.
 static bool unsupportedTypeConversion(const Sema &S, QualType LHSType,
                                       QualType RHSType) {
   if ((LHSType->isFixedPointType() && RHSType->isBitIntType()) ||

>From b160488c1f5431e070c061d3674068e720af0d21 Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 13:42:57 +0800
Subject: [PATCH 05/14] Update SemaExpr.cpp

---
 clang/lib/Sema/SemaExpr.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e6bad816d2d0a..aebb3a8bdc657 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1540,6 +1540,7 @@ 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

>From c398595fb509bc4631b62a446e1e67a1e9a7dc5c Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 15:55:54 +0800
Subject: [PATCH 06/14] Update SemaExpr.cpp

---
 clang/lib/Sema/SemaExpr.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index aebb3a8bdc657..650976250ec61 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1540,7 +1540,7 @@ 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

>From 5cc09e5bcf862cb66a36754d4fee5752574ca5a1 Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 16:03:13 +0800
Subject: [PATCH 07/14] Update fixed-point-bitint.c

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

diff --git a/clang/test/Sema/fixed-point-bitint.c 
b/clang/test/Sema/fixed-point-bitint.c
index 78f7cb787d571..d871ed06d8a02 100644
--- a/clang/test/Sema/fixed-point-bitint.c
+++ b/clang/test/Sema/fixed-point-bitint.c
@@ -1,5 +1,4 @@
 // RUN: %%clang_cc1 -ffixed-point -fsyntax-only -verify %%s 
- 
+
 constexpr _BitInt(128) i = 42; 
-static_assert(i == 42.0k); 
-// expected-error@-1 {{invalid operands to binary expression}} 
+static_assert(i == 42.0k); // expected-error {{invalid operands to binary 
expression}} 

>From e83b829d213a3e2c2378edef95dc126081045b30 Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 16:08:30 +0800
Subject: [PATCH 08/14] Update SemaExpr.cpp

---
 clang/lib/Sema/SemaExpr.cpp | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 650976250ec61..29d1824260444 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1282,12 +1282,10 @@ static QualType handleFloatConversion(Sema &S, 
ExprResult &LHS,
                                     /*ConvertInt=*/!IsCompAssign);
 }
 
-/// Diagnose attempts to convert between __float128, __ibm128 and
-/// long double if there is no support for such conversion.
-/// Helper function of UsualArithmeticConversions().
-/// Returns true if the conversion between LHSType and RHSType is not 
supported.
-/// This includes conversions between fixed point types and BitInt types,
-/// which would otherwise cause an assertion failure later.
+ /// Returns true if the conversion between LHSType and RHSType is not 
supported. 
+ /// This includes conversions between fixed point types and BitInt types, 
+ /// which would otherwise cause an assertion failure later.
+ /// Helper function of UsualArithmeticConversions().
 static bool unsupportedTypeConversion(const Sema &S, QualType LHSType,
                                       QualType RHSType) {
   if ((LHSType->isFixedPointType() && RHSType->isBitIntType()) ||

>From 02ae899547a092e604a192dd2f70112d0da1c3c4 Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 16:11:17 +0800
Subject: [PATCH 09/14] Update SemaExpr.cpp

---
 clang/lib/Sema/SemaExpr.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 29d1824260444..ee7527b74c553 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1282,10 +1282,9 @@ static QualType handleFloatConversion(Sema &S, 
ExprResult &LHS,
                                     /*ConvertInt=*/!IsCompAssign);
 }
 
- /// Returns true if the conversion between LHSType and RHSType is not 
supported. 
- /// This includes conversions between fixed point types and BitInt types, 
- /// which would otherwise cause an assertion failure later.
- /// Helper function of UsualArithmeticConversions().
+/// Returns true if the conversion between LHSType and RHSType is not 
supported. 
+/// This includes conversions between fixed point types and BitInt types.
+/// Helper function of UsualArithmeticConversions().
 static bool unsupportedTypeConversion(const Sema &S, QualType LHSType,
                                       QualType RHSType) {
   if ((LHSType->isFixedPointType() && RHSType->isBitIntType()) ||

>From ae3068af670cdec936336c18aaddf5759538a120 Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 21:14:43 +0800
Subject: [PATCH 10/14] Update SemaExpr.cpp

---
 clang/lib/Sema/SemaExpr.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ee7527b74c553..70a8b3e71062b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1287,9 +1287,6 @@ 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())
@@ -1755,7 +1752,11 @@ QualType Sema::UsualArithmeticConversions(ExprResult 
&LHS, ExprResult &RHS,
     return Context.getCommonSugaredType(LHSType, RHSType);
 
   // At this point, we have two different arithmetic types.
-
+  
+  if ((LHSType->isFixedPointType() && RHSType->isBitIntType()) ||
+      (LHSType->isBitIntType() && RHSType->isFixedPointType()))
+    return QualType();
+  
   // Diagnose attempts to convert between __ibm128, __float128 and long double
   // where such conversions currently can't be handled.
   if (unsupportedTypeConversion(*this, LHSType, RHSType))

>From ed20f95bfb7bd110ea08d7646ff4119925e448db Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 21:18:32 +0800
Subject: [PATCH 11/14] Update SemaExpr.cpp

---
 clang/lib/Sema/SemaExpr.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 70a8b3e71062b..40ffc1ce5eee4 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1282,8 +1282,8 @@ static QualType handleFloatConversion(Sema &S, ExprResult 
&LHS,
                                     /*ConvertInt=*/!IsCompAssign);
 }
 
-/// Returns true if the conversion between LHSType and RHSType is not 
supported. 
-/// This includes conversions between fixed point types and BitInt types.
+/// Diagnose attempts to convert between __float128, __ibm128 and
+/// long double if there is no support for such conversion.
 /// Helper function of UsualArithmeticConversions().
 static bool unsupportedTypeConversion(const Sema &S, QualType LHSType,
                                       QualType RHSType) {

>From 9a1f4acc098cb88779ce3c19781e892afaca3d1c Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 21:20:40 +0800
Subject: [PATCH 12/14] Update SemaExpr.cpp

---
 clang/lib/Sema/SemaExpr.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 40ffc1ce5eee4..86ffc21d27c8c 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1752,7 +1752,7 @@ QualType Sema::UsualArithmeticConversions(ExprResult 
&LHS, ExprResult &RHS,
     return Context.getCommonSugaredType(LHSType, RHSType);
 
   // At this point, we have two different arithmetic types.
-  
+
   if ((LHSType->isFixedPointType() && RHSType->isBitIntType()) ||
       (LHSType->isBitIntType() && RHSType->isFixedPointType()))
     return QualType();

>From 22bf6fdb183040a43bab17672c9178d81b7f9b4a Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Thu, 28 May 2026 21:22:01 +0800
Subject: [PATCH 13/14] Update SemaExpr.cpp

---
 clang/lib/Sema/SemaExpr.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 86ffc21d27c8c..a3159484d8ca9 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1287,7 +1287,6 @@ static QualType handleFloatConversion(Sema &S, ExprResult 
&LHS,
 /// Helper function of UsualArithmeticConversions().
 static bool unsupportedTypeConversion(const Sema &S, QualType LHSType,
                                       QualType RHSType) {
-
   // No issue if either is not a floating point type.
   if (!LHSType->isFloatingType() || !RHSType->isFloatingType())
     return false;

>From 15058e5a72d96e003030da5bea75689ed52d3a54 Mon Sep 17 00:00:00 2001
From: superdusty <[email protected]>
Date: Sun, 31 May 2026 23:25:31 +0800
Subject: [PATCH 14/14] Delete clang/test/Sema/fixed-point-bitint.c

---
 clang/test/Sema/fixed-point-bitint.c | 4 ----
 1 file changed, 4 deletions(-)
 delete mode 100644 clang/test/Sema/fixed-point-bitint.c

diff --git a/clang/test/Sema/fixed-point-bitint.c 
b/clang/test/Sema/fixed-point-bitint.c
deleted file mode 100644
index d871ed06d8a02..0000000000000
--- a/clang/test/Sema/fixed-point-bitint.c
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %%clang_cc1 -ffixed-point -fsyntax-only -verify %%s 
-
-constexpr _BitInt(128) i = 42; 
-static_assert(i == 42.0k); // expected-error {{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