Skip to content

Commit 79f8e90

Browse files
committed
[flang] Avoid bogus warning from MSVC build
And expand common::BitSet from 64 to 128 maximum elements. Differential Revision: https://reviews.llvm.org/D120848
1 parent ad786f5 commit 79f8e90

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

flang/include/flang/Common/constexpr-bitset.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
#define FORTRAN_COMMON_CONSTEXPR_BITSET_H_
1111

1212
// Implements a replacement for std::bitset<> that is suitable for use
13-
// in constexpr expressions. Limited to elements in [0..63].
13+
// in constexpr expressions. Limited to elements in [0..127].
1414

1515
#include "bit-population-count.h"
16+
#include "uint128.h"
1617
#include <cstddef>
1718
#include <cstdint>
1819
#include <initializer_list>
@@ -22,11 +23,10 @@
2223
namespace Fortran::common {
2324

2425
template <int BITS> class BitSet {
25-
static_assert(BITS > 0 && BITS <= 64);
26-
static constexpr bool partialWord{BITS != 32 && BITS != 64};
27-
using Word = std::conditional_t<(BITS > 32), std::uint64_t, std::uint32_t>;
26+
static_assert(BITS > 0 && BITS <= 128);
27+
using Word = HostUnsignedIntType<(BITS <= 32 ? 32 : BITS)>;
2828
static constexpr Word allBits{
29-
partialWord ? (static_cast<Word>(1) << BITS) - 1 : ~static_cast<Word>(0)};
29+
~static_cast<Word>(0) >> (8 * sizeof(Word) - BITS)};
3030

3131
constexpr BitSet(Word b) : bits_{b} {}
3232

0 commit comments

Comments
 (0)