[flang-commits] [flang] 7ffad37 - [flang][OpenMP] Avoid captures of references to structured bindings

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Wed Dec 20 13:32:43 PST 2023


Author: Krzysztof Parzyszek
Date: 2023-12-20T15:31:49-06:00
New Revision: 7ffad37c8694ef2ed554074bc6c622e7ceeb4624

URL: https://github.com/llvm/llvm-project/commit/7ffad37c8694ef2ed554074bc6c622e7ceeb4624
DIFF: https://github.com/llvm/llvm-project/commit/7ffad37c8694ef2ed554074bc6c622e7ceeb4624.diff

LOG: [flang][OpenMP] Avoid captures of references to structured bindings

Fixes build break caused by 400c32cbf9.

Added: 
    

Modified: 
    flang/lib/Lower/OpenMP.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index f882d307cf5be1..1acc49abb1da00 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -2489,38 +2489,38 @@ static void genBodyOfTargetOp(
   // Bind the symbols to their corresponding block arguments.
   for (auto [argIndex, argSymbol] : llvm::enumerate(mapSymbols)) {
     const mlir::BlockArgument &arg = region.getArgument(argIndex);
-    fir::ExtendedValue extVal = converter.getSymbolExtendedValue(*argSymbol);
+    // Avoid capture of reference to a structured binding.
+    const Fortran::semantics::Symbol *sym = argSymbol;
+    fir::ExtendedValue extVal = converter.getSymbolExtendedValue(*sym);
     extVal.match(
         [&](const fir::BoxValue &v) {
-          converter.bindSymbol(*argSymbol,
+          converter.bindSymbol(*sym,
                                fir::BoxValue(arg, cloneBounds(v.getLBounds()),
                                              v.getExplicitParameters(),
                                              v.getExplicitExtents()));
         },
         [&](const fir::MutableBoxValue &v) {
           converter.bindSymbol(
-              *argSymbol, fir::MutableBoxValue(arg, cloneBounds(v.getLBounds()),
-                                               v.getMutableProperties()));
+              *sym, fir::MutableBoxValue(arg, cloneBounds(v.getLBounds()),
+                                         v.getMutableProperties()));
         },
         [&](const fir::ArrayBoxValue &v) {
           converter.bindSymbol(
-              *argSymbol, fir::ArrayBoxValue(arg, cloneBounds(v.getExtents()),
-                                             cloneBounds(v.getLBounds()),
-                                             v.getSourceBox()));
+              *sym, fir::ArrayBoxValue(arg, cloneBounds(v.getExtents()),
+                                       cloneBounds(v.getLBounds()),
+                                       v.getSourceBox()));
         },
         [&](const fir::CharArrayBoxValue &v) {
           converter.bindSymbol(
-              *argSymbol, fir::CharArrayBoxValue(arg, cloneBound(v.getLen()),
-                                                 cloneBounds(v.getExtents()),
-                                                 cloneBounds(v.getLBounds())));
+              *sym, fir::CharArrayBoxValue(arg, cloneBound(v.getLen()),
+                                           cloneBounds(v.getExtents()),
+                                           cloneBounds(v.getLBounds())));
         },
         [&](const fir::CharBoxValue &v) {
-          converter.bindSymbol(*argSymbol,
+          converter.bindSymbol(*sym,
                                fir::CharBoxValue(arg, cloneBound(v.getLen())));
         },
-        [&](const fir::UnboxedValue &v) {
-          converter.bindSymbol(*argSymbol, arg);
-        },
+        [&](const fir::UnboxedValue &v) { converter.bindSymbol(*sym, arg); },
         [&](const auto &) {
           TODO(converter.getCurrentLocation(),
                "target map clause operand unsupported type");


        


More information about the flang-commits mailing list