[flang-commits] [flang] 75a5ec1 - [flang][msvc] Rework a MSVC work-around to avoid clang warning

peter klausler via flang-commits flang-commits at lists.llvm.org
Thu Oct 1 16:53:17 PDT 2020


Author: peter klausler
Date: 2020-10-01T16:52:30-07:00
New Revision: 75a5ec1bad18ae1d741830cc46946da00fed6ed9

URL: https://github.com/llvm/llvm-project/commit/75a5ec1bad18ae1d741830cc46946da00fed6ed9
DIFF: https://github.com/llvm/llvm-project/commit/75a5ec1bad18ae1d741830cc46946da00fed6ed9.diff

LOG: [flang][msvc] Rework a MSVC work-around to avoid clang warning

A recent MSVC work-around patch is eliciting unused variable
warnings from clang; package the lambda reference arguments
into a struct to avoid the warning.

Differential revision: https://reviews.llvm.org/D88695

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index 8178b277d13b..f89cbf787220 100644
--- a/flang/lib/Evaluate/fold-implementation.h
+++ b/flang/lib/Evaluate/fold-implementation.h
@@ -1154,14 +1154,20 @@ Expr<TO> FoldOperation(
   if (auto array{ApplyElementwise(context, convert)}) {
     return *array;
   }
+  struct {
+    FoldingContext &context;
+    Convert<TO, FROMCAT> &convert;
+  } msvcWorkaround{context, convert};
   return std::visit(
-      [&context, &convert](auto &kindExpr) -> Expr<TO> {
+      [&msvcWorkaround](auto &kindExpr) -> Expr<TO> {
         using Operand = ResultType<decltype(kindExpr)>;
         // This variable is a workaround for msvc which emits an error when
         // using the FROMCAT template parameter below.
         TypeCategory constexpr FromCat{FROMCAT};
+        auto &convert{msvcWorkaround.convert};
         char buffer[64];
         if (auto value{GetScalarConstantValue<Operand>(kindExpr)}) {
+          FoldingContext &context{msvcWorkaround.context};
           if constexpr (TO::category == TypeCategory::Integer) {
             if constexpr (Operand::category == TypeCategory::Integer) {
               auto converted{Scalar<TO>::ConvertSigned(*value)};


        


More information about the flang-commits mailing list