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/9] [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/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 8/9] 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 9/9] 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()) ||

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

Reply via email to