[clang] [clang][bytecode] 0 bitwidth IntAP values also use one word (PR #193224)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 21 06:45:59 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
Not 0. This can happen in error cases.
---
Full diff: https://github.com/llvm/llvm-project/pull/193224.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/IntegralAP.h (+1-1)
- (modified) clang/test/AST/ByteCode/intap.cpp (+4)
``````````diff
diff --git a/clang/lib/AST/ByteCode/IntegralAP.h b/clang/lib/AST/ByteCode/IntegralAP.h
index 9f53ac7716bba..061038cde7081 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 804b16484ca01..5c3e9f979e129 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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/193224
More information about the cfe-commits
mailing list