[PATCH] D88509: [flang][msvc] Define implicit conversion from UnsignedInt128 to int64_t.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 12:08:05 PDT 2020


Meinersbur created this revision.
Meinersbur added reviewers: isuruf, DavidTruby, sscalpone, klausler, tskeith.
Meinersbur added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Meinersbur requested review of this revision.

The custom implementation of UnsignedInt128 has an implicit conversion operator to unit64_t, but not int64_t. Considering that the former is already truncating, and C++ implicitly converts uint64_t to int64_t, UnsignedInt128  should also support an implicit conversion to int64_t. An analogous conversion would be from uint32_t to int64_t.

Without the conversion operator overload, the msvc emits the following error:

  descriptor-io.h(44): error C2440: 'static_cast': cannot convert from 'A' to 'int64_t'
          with
          [
              A=Fortran::common::uint128_t
          ]

This patch is part of the series to make flang compilable with MS Visual Studio http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88509

Files:
  flang/include/flang/Common/uint128.h


Index: flang/include/flang/Common/uint128.h
===================================================================
--- flang/include/flang/Common/uint128.h
+++ flang/include/flang/Common/uint128.h
@@ -53,6 +53,7 @@
   constexpr bool operator!() const { return !low_ && !high_; }
   constexpr explicit operator bool() const { return low_ || high_; }
   constexpr explicit operator std::uint64_t() const { return low_; }
+  constexpr explicit operator std::int64_t() const { return low_; }
   constexpr explicit operator int() const { return static_cast<int>(low_); }
 
   constexpr std::uint64_t high() const { return high_; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88509.295076.patch
Type: text/x-patch
Size: 623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200929/1b9487f1/attachment.bin>


More information about the llvm-commits mailing list