[clang] 12411c1 - [clang][bytecode] 0 bitwidth IntAP values also use one word (#193224)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 23 03:51:26 PDT 2026
Author: Timm Baeder
Date: 2026-04-23T12:51:21+02:00
New Revision: 12411c1e6ac577e4144aa541c3c4be87dff68d2a
URL: https://github.com/llvm/llvm-project/commit/12411c1e6ac577e4144aa541c3c4be87dff68d2a
DIFF: https://github.com/llvm/llvm-project/commit/12411c1e6ac577e4144aa541c3c4be87dff68d2a.diff
LOG: [clang][bytecode] 0 bitwidth IntAP values also use one word (#193224)
Not 0. This can happen in error cases.
Added:
Modified:
clang/lib/AST/ByteCode/IntegralAP.h
clang/test/AST/ByteCode/intap.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/IntegralAP.h b/clang/lib/AST/ByteCode/IntegralAP.h
index 9f53ac7716bbaa..061038cde70817 100644
--- a/clang/lib/AST/ByteCode/IntegralAP.h
+++ b/clang/lib/AST/ByteCode/IntegralAP.h
@@ -138,7 +138,7 @@ template <bool Signed> class IntegralAP final {
constexpr uint32_t bitWidth() const { return BitWidth; }
constexpr unsigned numWords() const { return APInt::getNumWords(BitWidth); }
- constexpr bool singleWord() const { return numWords() == 1; }
+ constexpr bool singleWord() const { return numWords() <= 1; }
constexpr static bool isNumber() { return true; }
APSInt toAPSInt(unsigned Bits = 0) const {
diff --git a/clang/test/AST/ByteCode/intap.cpp b/clang/test/AST/ByteCode/intap.cpp
index 804b16484ca01d..5c3e9f979e1292 100644
--- a/clang/test/AST/ByteCode/intap.cpp
+++ b/clang/test/AST/ByteCode/intap.cpp
@@ -69,6 +69,10 @@ constexpr _BitInt(32) nope = top / bottom; // both-error {{must be initialized
constexpr _BitInt(32) noooo = top % bottom; // both-error {{must be initialized by a constant expression}} \
// both-note {{value 2147483648 is outside the range}}
+struct {
+ _BitInt(35) void : 33; // both-error {{cannot combine with previous '_BitInt' declaration specifier}}
+} s;
+
namespace APCast {
constexpr _BitInt(10) A = 1;
constexpr _BitInt(11) B = A;
More information about the cfe-commits
mailing list