[flang-commits] [flang] [flang][OpenMP] Avoid crash with MAP w/o modifiers, version >= 6.0 (PR #154352)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Tue Aug 19 07:51:05 PDT 2025
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/154352
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.
>From bda70683b3241563d6f16450dae144d5396becb5 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Tue, 19 Aug 2025 09:43:00 -0500
Subject: [PATCH] [flang][OpenMP] Avoid crash with MAP w/o modifiers, version
>= 6.0
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.
---
flang/lib/Semantics/resolve-directives.cpp | 3 ++-
flang/test/Lower/OpenMP/map-no-modifier-v60.f90 | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 flang/test/Lower/OpenMP/map-no-modifier-v60.f90
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
+
More information about the flang-commits
mailing list