[flang-commits] [flang] b554306 - [flang][msvc] Define implicit conversion from UnsignedInt128 to int64_t.
Michael Kruse via flang-commits
flang-commits at lists.llvm.org
Tue Sep 29 14:41:55 PDT 2020
Author: Michael Kruse
Date: 2020-09-29T16:41:46-05:00
New Revision: b5543063e1bfd6195a2d34d2c892466c0050e08a
URL: https://github.com/llvm/llvm-project/commit/b5543063e1bfd6195a2d34d2c892466c0050e08a
DIFF: https://github.com/llvm/llvm-project/commit/b5543063e1bfd6195a2d34d2c892466c0050e08a.diff
LOG: [flang][msvc] Define implicit conversion from UnsignedInt128 to int64_t.
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 int16_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>.
Reviewed By: klausler
Differential Revision: https://reviews.llvm.org/D88509
Added:
Modified:
flang/include/flang/Common/uint128.h
Removed:
################################################################################
diff --git a/flang/include/flang/Common/uint128.h b/flang/include/flang/Common/uint128.h
index eecf4a8ba114..0ed3cf1f385d 100644
--- a/flang/include/flang/Common/uint128.h
+++ b/flang/include/flang/Common/uint128.h
@@ -53,6 +53,7 @@ class UnsignedInt128 {
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_; }
More information about the flang-commits
mailing list