[PATCH] D120848: [flang] Fix warning from MSVC build

Peter Klausler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 2 15:24:04 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79f8e909ed63: [flang] Avoid bogus warning from MSVC build (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120848/new/

https://reviews.llvm.org/D120848

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


Index: flang/include/flang/Common/constexpr-bitset.h
===================================================================
--- flang/include/flang/Common/constexpr-bitset.h
+++ flang/include/flang/Common/constexpr-bitset.h
@@ -10,9 +10,10 @@
 #define FORTRAN_COMMON_CONSTEXPR_BITSET_H_
 
 // Implements a replacement for std::bitset<> that is suitable for use
-// in constexpr expressions.  Limited to elements in [0..63].
+// in constexpr expressions.  Limited to elements in [0..127].
 
 #include "bit-population-count.h"
+#include "uint128.h"
 #include <cstddef>
 #include <cstdint>
 #include <initializer_list>
@@ -22,11 +23,10 @@
 namespace Fortran::common {
 
 template <int BITS> class BitSet {
-  static_assert(BITS > 0 && BITS <= 64);
-  static constexpr bool partialWord{BITS != 32 && BITS != 64};
-  using Word = std::conditional_t<(BITS > 32), std::uint64_t, std::uint32_t>;
+  static_assert(BITS > 0 && BITS <= 128);
+  using Word = HostUnsignedIntType<(BITS <= 32 ? 32 : BITS)>;
   static constexpr Word allBits{
-      partialWord ? (static_cast<Word>(1) << BITS) - 1 : ~static_cast<Word>(0)};
+      ~static_cast<Word>(0) >> (8 * sizeof(Word) - BITS)};
 
   constexpr BitSet(Word b) : bits_{b} {}
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120848.412559.patch
Type: text/x-patch
Size: 1213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220302/ad7b0b2e/attachment.bin>


More information about the llvm-commits mailing list