diff --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp index 173dceb07b193..711d4af287691 100644 --- a/flang/lib/Lower/OpenMP/Utils.cpp +++ b/flang/lib/Lower/OpenMP/Utils.cpp @@ -362,16 +362,18 @@ mlir::Value createParentSymAndGenIntermediateMaps( clauseLocation, firOpBuilder.getRefType(memberTy), curValue, llvm::SmallVector{idxConst}); - // Skip mapping and the subsequent load if we're the final member or not - // a type with a descriptor such as a pointer/allocatable. If we're a - // final member, the map will be generated by the processMap call that - // invoked this function, and if we're not a type with a descriptor then - // we have no need of generating an intermediate map for it, as we only - // need to generate a map if a member is a descriptor type (and thus - // obscures the members it contains via a pointer in which it's data needs - // mapped) - if ((currentIndicesIdx == indices.size() - 1) || - !fir::isTypeWithDescriptor(memberTy)) { + // If we're a final member, the map will be generated by the processMap + // call that invoked this function. + if (currentIndicesIdx == indices.size() - 1) + break; + + // Skip mapping and the subsequent load if we're not + // a type with a descriptor such as a pointer/allocatable. If we're not a + // type with a descriptor then we have no need of generating an + // intermediate map for it, as we only need to generate a map if a member + // is a descriptor type (and thus obscures the members it contains via a + // pointer in which it's data needs mapped). + if (!fir::isTypeWithDescriptor(memberTy)) { currentIndicesIdx++; continue; }