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

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Mon Jun 16 07:08:57 PDT 2025


https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/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.

>From a5d8ab660b6f1893d2577452f2b0ca1d6bc2b4c5 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Mon, 16 Jun 2025 08:30:11 -0500
Subject: [PATCH] [flang][OpenMP] Don't crash on iterator modifier in declare
 mapper

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.
---
 flang/lib/Semantics/resolve-names.cpp                 |  2 +-
 .../Lower/OpenMP/Todo/declare-mapper-iterator.f90     | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Lower/OpenMP/Todo/declare-mapper-iterator.f90

diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index e23e91b674a73..0de642b2bd8df 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1801,9 +1801,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