[PATCH] D88504: [flang][msvc] Workaround 'forgotten' symbols FoldOperation. NFC.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 10:31:23 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.

This resolves an issue where the Microsoft compiler 'forgets' symbols when using constexpr in a lambda in a templated function. The symbols are:

1. The implicit lambda captures `context` and `convert`. Fix by making them explicit captures. The error message was:

  fold-implementation.h(1220): error C2065: 'convert': undeclared identifier



2. The function template argument FROMCAT. Fix by storing it in a temporary constexpr variable inside the function. The error message was:

  fold-implementation.h(1216): error C2065: 'FROMCAT': undeclared identifier

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/D88504

Files:
  flang/lib/Evaluate/fold-implementation.h


Index: flang/lib/Evaluate/fold-implementation.h
===================================================================
--- flang/lib/Evaluate/fold-implementation.h
+++ flang/lib/Evaluate/fold-implementation.h
@@ -1155,8 +1155,9 @@
     return *array;
   }
   return std::visit(
-      [&](auto &kindExpr) -> Expr<TO> {
+      [&context, &convert](auto &kindExpr) -> Expr<TO> {
         using Operand = ResultType<decltype(kindExpr)>;
+        TypeCategory constexpr FromCat = FROMCAT;
         char buffer[64];
         if (auto value{GetScalarConstantValue<Operand>(kindExpr)}) {
           if constexpr (TO::category == TypeCategory::Integer) {
@@ -1213,7 +1214,7 @@
             return Expr<TO>{value->IsTrue()};
           }
         } else if constexpr (std::is_same_v<Operand, TO> &&
-            FROMCAT != TypeCategory::Character) {
+            FromCat != TypeCategory::Character) {
           return std::move(kindExpr); // remove needless conversion
         }
         return Expr<TO>{std::move(convert)};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88504.295020.patch
Type: text/x-patch
Size: 1015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200929/9c14ed51/attachment.bin>


More information about the llvm-commits mailing list