[flang-commits] [flang] [flang][OpenMP] Avoid crash with MAP w/o modifiers, version >= 6.0 (PR #154352)
via flang-commits
flang-commits at lists.llvm.org
Tue Aug 19 07:51:37 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Krzysztof Parzyszek (kparzysz)
<details>
<summary>Changes</summary>
The current code will crash on the MAP clause with OpenMP version >= 6.0 when the clause does not explicitly list any modifiers. The proper fix is to update the handling of assumed-size arrays for OpenMP 6.0+, but in the short term keep the behavior from 5.2, just avoid the crash.
---
Full diff: https://github.com/llvm/llvm-project/pull/154352.diff
2 Files Affected:
- (modified) flang/lib/Semantics/resolve-directives.cpp (+2-1)
- (added) flang/test/Lower/OpenMP/map-no-modifier-v60.f90 (+12)
``````````diff
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index fe0d2a73805de..6a4660c9882ab 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -793,7 +793,8 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
if (name->symbol) {
name->symbol->set(
ompFlag.value_or(Symbol::Flag::OmpMapStorage));
- AddToContextObjectWithDSA(*name->symbol, *ompFlag);
+ AddToContextObjectWithDSA(*name->symbol,
+ ompFlag.value_or(Symbol::Flag::OmpMapStorage));
if (semantics::IsAssumedSizeArray(*name->symbol)) {
context_.Say(designator.source,
"Assumed-size whole arrays may not appear on the %s "
diff --git a/flang/test/Lower/OpenMP/map-no-modifier-v60.f90 b/flang/test/Lower/OpenMP/map-no-modifier-v60.f90
new file mode 100644
index 0000000000000..bcc37e48f8c11
--- /dev/null
+++ b/flang/test/Lower/OpenMP/map-no-modifier-v60.f90
@@ -0,0 +1,12 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=60 %s -o - | FileCheck %s
+
+!This shouldn't crash. Check for a symptom of a successful compilation
+!CHECK: omp.map.info
+
+subroutine f00
+ implicit none
+ integer :: x
+ !$omp target map(x)
+ !$omp end target
+end
+
``````````
</details>
https://github.com/llvm/llvm-project/pull/154352
More information about the flang-commits
mailing list