[flang-commits] [flang] Fix semantic check for default declare mappers (PR #139593)

Akash Banerjee via flang-commits flang-commits at lists.llvm.org
Thu May 15 06:35:33 PDT 2025


================
@@ -1783,6 +1776,18 @@ void OmpVisitor::ProcessMapperSpecifier(const parser::OmpMapperSpecifier &spec,
   Walk(clauses);
   EndDeclTypeSpec();
   PopScope();
+
+  if (auto &mapperName{std::get<std::optional<parser::Name>>(spec.t)}) {
+    mapperName->symbol =
+        &MakeSymbol(*mapperName, MiscDetails{MiscDetails::Kind::ConstructName});
+  } else {
+    const auto &type = std::get<parser::TypeSpec>(spec.t);
+    static llvm::SmallVector<std::string> defaultNames;
----------------
TIFitis wrote:

Hi, I encountered that even with this minor fix, some separate scoping related semantic issues would have still remained. To fix these issues altogether, I have instead taken a different approach to solving the problem.

I have changed the optional<name> field for the mapper name to a compulsory std::string field. The parser has been updated to create a default name - `"<typeSpec>.omp.default.mapper"` whenever the default name is used.

Also added a new test to _flang/test/Lower/OpenMP/declare-mapper.f90_ for ensuring declare mapper scoping rules apply cleanly.

https://github.com/llvm/llvm-project/pull/139593


More information about the flang-commits mailing list