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

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Tue May 13 09:00:38 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;
----------------
skatrak wrote:

I can see this is intentionally `static` to make sure that these runtime-created strings don't get destructed while symbols are still in use, since `CharBlock` doesn't own the data, but it doesn't seem to me like a very clean approach.

Not sure if perhaps adding some generic static storage for situations like this to the `semantics::Scope` class, something looking similar to the `allSymbols` field, would be a better idea or if there currently are any facilities to store strings not present in the original source to be used as symbols.

CC: @kiranchandramohan, @tblah.

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


More information about the flang-commits mailing list