https://github.com/superdusty updated https://github.com/llvm/llvm-project/pull/199912
>From 7f9ee7c71a1d5f449dfcd3339934b860a7bc188c Mon Sep 17 00:00:00 2001 From: cry <[email protected]> Date: Wed, 27 May 2026 17:30:06 +0800 Subject: [PATCH] [Clang] Fix crash when comparing fixed point type with BitInt --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Sema/SemaExpr.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 6838cf3defcc1..9820375655d81 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -564,6 +564,7 @@ Bug Fixes in This Version - Fixed a failed assertion in the preprocessor when ``__has_embed`` parameters are missing parentheses. (#GH175088) - Fix lifetime extension of temporaries in for-range-initializers in templates. (#GH165182) - Fixed a preprocessor crash in ``__has_cpp_attribute`` on incomplete scoped attributes. (#GH178098) +- Fixed a crash when comparing a fixed point type with a ``_BitInt`` type. (#GH196948) - Fixes an assertion failure when evaluating ``__underlying_type`` on enum redeclarations. (#GH177943) - Fixed an assertion failure caused by nested macro expansion during header-name lexing (``__has_embed(__has_include)``). (#GH178635) - Clang now outputs relative paths of embeds for dependency output. (#GH161950) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 521a8516ac179..2f79ff3edcb79 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; @@ -1534,6 +1538,12 @@ static QualType handleFixedPointConversion(Sema &S, QualType LHSTy, "Special fixed point arithmetic operation conversions are only " "applied to ints or other fixed point types"); + // If either type is BitInt, return an empty type to avoid crashing + // when GetFixedPointRank is called later. + if (LHSTy->isBitIntType() || RHSTy->isBitIntType()) { + return QualType(); + } + // 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 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
