[flang-commits] [flang] 8255d24 - [flang][OpenMP] Avoid crash with MAP w/o modifiers, version >= 6.0 (#154352)

via flang-commits flang-commits at lists.llvm.org
Tue Aug 19 08:18:54 PDT 2025


Author: Krzysztof Parzyszek
Date: 2025-08-19T10:18:51-05:00
New Revision: 8255d240a96405e2ae24b61153bbca18854a6796

URL: https://github.com/llvm/llvm-project/commit/8255d240a96405e2ae24b61153bbca18854a6796
DIFF: https://github.com/llvm/llvm-project/commit/8255d240a96405e2ae24b61153bbca18854a6796.diff

LOG: [flang][OpenMP] Avoid crash with MAP w/o modifiers, version >= 6.0 (#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.

Added: 
    flang/test/Lower/OpenMP/map-no-modifier-v60.f90

Modified: 
    flang/lib/Semantics/resolve-directives.cpp

Removed: 
    


################################################################################
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