constant: Support suffixes for integers that otherwise would be narrowed.

This commit is contained in:
Emilio Cobos Álvarez
2022-06-07 16:03:55 +02:00
parent a79a10d9a6
commit 597b033ccf
14 changed files with 129 additions and 21 deletions
+35 -1
View File
@@ -86,8 +86,42 @@ struct DebugFlags {
/// Flag with the topmost bit set of the u32
constexpr static const DebugFlags DebugFlags_BIGGEST_ALLOWED = DebugFlags{ /* .bits = */ (uint32_t)(1 << 31) };
struct LargeFlags {
uint64_t bits;
explicit operator bool() const {
return !!bits;
}
LargeFlags operator~() const {
return {static_cast<decltype(bits)>(~bits)};
}
LargeFlags operator|(const LargeFlags& other) const {
return {static_cast<decltype(bits)>(this->bits | other.bits)};
}
LargeFlags& operator|=(const LargeFlags& other) {
*this = (*this | other);
return *this;
}
LargeFlags operator&(const LargeFlags& other) const {
return {static_cast<decltype(bits)>(this->bits & other.bits)};
}
LargeFlags& operator&=(const LargeFlags& other) {
*this = (*this & other);
return *this;
}
LargeFlags operator^(const LargeFlags& other) const {
return {static_cast<decltype(bits)>(this->bits ^ other.bits)};
}
LargeFlags& operator^=(const LargeFlags& other) {
*this = (*this ^ other);
return *this;
}
};
/// Flag with a very large shift that usually would be narrowed.
constexpr static const LargeFlags LargeFlags_LARGE_SHIFT = LargeFlags{ /* .bits = */ (uint64_t)(1ull << 44) };
extern "C" {
void root(AlignFlags flags, DebugFlags bigger_flags);
void root(AlignFlags flags, DebugFlags bigger_flags, LargeFlags largest_flags);
} // extern "C"