[flang-commits] [flang] 4b2ab14 - [flang][OpenMP] Don't crash on iterator modifier in declare mapper (#144359)

via flang-commits flang-commits at lists.llvm.org
Wed Jun 18 05:46:52 PDT 2025


Author: Krzysztof Parzyszek
Date: 2025-06-18T07:46:49-05:00
New Revision: 4b2ab1494bc07493087252dff4e5e19808703048

URL: https://github.com/llvm/llvm-project/commit/4b2ab1494bc07493087252dff4e5e19808703048
DIFF: https://github.com/llvm/llvm-project/commit/4b2ab1494bc07493087252dff4e5e19808703048.diff

LOG: [flang][OpenMP] Don't crash on iterator modifier in declare mapper (#144359)

Both the declare mapper directive argument, and the iterator modifier
can contain declaration-type-spec, so make sure that the processing of
one ends before processing of the other begins in semantic analysis.

Added: 
    flang/test/Lower/OpenMP/Todo/declare-mapper-iterator.f90

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

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index f66918e5c140e..9e465f8ff3e1e 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1800,9 +1800,9 @@ void OmpVisitor::ProcessMapperSpecifier(const parser::OmpMapperSpecifier &spec,
   Walk(std::get<parser::TypeSpec>(spec.t));
   auto &varName{std::get<parser::Name>(spec.t)};
   DeclareObjectEntity(varName);
+  EndDeclTypeSpec();
 
   Walk(clauses);
-  EndDeclTypeSpec();
   PopScope();
 }
 

diff  --git a/flang/test/Lower/OpenMP/Todo/declare-mapper-iterator.f90 b/flang/test/Lower/OpenMP/Todo/declare-mapper-iterator.f90
new file mode 100644
index 0000000000000..dacd6d6246595
--- /dev/null
+++ b/flang/test/Lower/OpenMP/Todo/declare-mapper-iterator.f90
@@ -0,0 +1,11 @@
+!RUN: %not_todo_cmd %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -o - %s 2>&1 | FileCheck %s
+
+!CHECK: Support for iterator modifiers is not implemented yet
+subroutine f(arg)
+  type :: s
+    integer :: a(10)
+  end type
+  type(s) :: arg(:)
+
+  !$omp declare mapper(m: s :: v) map(mapper(m), iterator(i = 1:10): v%a(i))
+end


        


More information about the flang-commits mailing list