From 791200b3bc6898f478138b63e91c03f0c68c7061 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 21 Dec 2023 08:39:57 -0600 Subject: [PATCH] [flang][OpenMP] Avoid captures of references to structured bindings Handle one more case missed in ad37c8694e. --- flang/lib/Lower/OpenMP.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index 1acc49abb1da00..8ed31766725e14 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -2197,10 +2197,12 @@ static void genBodyOfTargetDataOp( if (fir::isa_builtin_cptr_type(refType.getElementType())) { converter.bindSymbol(*argSymbol, arg); } else { + // Avoid capture of a reference to a structured binding. + const Fortran::semantics::Symbol *sym = argSymbol; extVal.match( [&](const fir::MutableBoxValue &mbv) { converter.bindSymbol( - *argSymbol, + *sym, fir::MutableBoxValue( arg, fir::factory::getNonDeferredLenParams(extVal), {})); }, @@ -2489,7 +2491,7 @@ 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); - // Avoid capture of reference to a structured binding. + // Avoid capture of a reference to a structured binding. const Fortran::semantics::Symbol *sym = argSymbol; fir::ExtendedValue extVal = converter.getSymbolExtendedValue(*sym); extVal.match(