[flang][MSVC] Work around what seems to be a bogus MSVC error
authorPeter Klausler <pklausler@nvidia.com>
Sun, 30 Oct 2022 19:40:19 +0000 (12:40 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Sun, 30 Oct 2022 19:59:01 +0000 (12:59 -0700)
Recode a recent patch in an attempt to dodge a nonsensical error
from MSVC 14.

flang/lib/Evaluate/fold-integer.cpp

index 1efb741..f72a5a0 100644 (file)
@@ -611,12 +611,15 @@ Expr<Type<TypeCategory::Integer, KIND>> FoldIntrinsicFunction(
       } else {
         return common::visit(
             [&funcRef, &context, &FromInt64](const auto &str) -> Expr<T> {
-              using Char = typename std::decay_t<decltype(str)>::Result;
-              return FoldElementalIntrinsic<T, Char>(context,
+              using CharTy = typename std::decay_t<decltype(str)>::Result;
+              constexpr int charKind{CharTy::kind};
+              using MSVCWorkaround = Type<TypeCategory::Character, charKind>;
+              return FoldElementalIntrinsic<T, MSVCWorkaround>(context,
                   std::move(funcRef),
-                  ScalarFunc<T, Char>([&FromInt64](const Scalar<Char> &c) {
-                    return FromInt64(CharacterUtils<Char::kind>::ICHAR(c));
-                  }));
+                  ScalarFunc<T, MSVCWorkaround>(
+                      [&FromInt64](const Scalar<MSVCWorkaround> &c) {
+                        return FromInt64(CharacterUtils<charKind>::ICHAR(c));
+                      }));
             },
             someChar->u);
       }