[clang] [clang][bytecode] Loosen a __builtin_subcb assertion (PR #202284)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 8 01:07:41 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/202284
The types should match, but `QualType`s can't be compared with `==` like that.
>From 060183b2316c2fa6752e94731980014193db7bb8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 8 Jun 2026 10:04:42 +0200
Subject: [PATCH] [clang][bytecode] Loosen a __builtin_subcb assertion
The types should match, but `QualType`s can't be compared with `==` like
that.
---
clang/lib/AST/ByteCode/InterpBuiltin.cpp | 3 ++-
clang/test/AST/ByteCode/builtin-functions.cpp | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 501c7f76a0376..df9aec6789a57 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1025,7 +1025,8 @@ static bool interp__builtin_carryop(InterpState &S, CodePtr OpPC,
if (CarryOutPtr.canBeInitialized())
CarryOutPtr.initialize();
- assert(Call->getType() == Call->getArg(0)->getType());
+ assert(S.getASTContext().hasSimilarType(Call->getType(),
+ Call->getArg(0)->getType()));
pushInteger(S, Result, Call->getType());
return true;
}
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp
index 214cb06a27d99..57157392f6a6e 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -2071,4 +2071,12 @@ namespace SubCb {
return __builtin_subcb(lhs, rhs, carry, &rhs);
}
static_assert(subcb(10, 15, 1) == 250);
+
+ using u8 = unsigned char;
+ constexpr int subcb2() {
+ u8 a = 0, b = 0, c = 0;
+ __builtin_subcb(a, b, c, &c);
+ return 0;
+ }
+ static_assert(subcb2() == 0);
}
More information about the cfe-commits
mailing list