[flang-commits] [flang] [Flang][OpenMP] Initial defaultmap(none) implementation (PR #166715)

via flang-commits flang-commits at lists.llvm.org
Mon Nov 10 10:25:14 PST 2025


================
@@ -3000,6 +3066,36 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
       }
     }
 
+    // TODO: handle case where default and defaultmap are present on the same
+    // construct and conflict, defaultmap should supersede default if they
+    // conflict.
+    if (!GetContext().defaultMap.empty()) {
+      // Checked before implicit data sharing attributes as this rule ignores
+      // them and expects explicit predetermined/specified attributes to be in
+      // place for the types specified.
+      if (Symbol * found{currScope().FindSymbol(name.source)}) {
+        // If the variable has declare target applied to it (enter or link) it
+        // is exempt from defaultmap(none) restrictions
+        if (!symbol->GetUltimate().test(Symbol::Flag::OmpDeclareTarget)) {
+          auto &dMap = GetContext().defaultMap;
+          for (auto defaults : dMap) {
+            if (defaults.second ==
+                parser::OmpDefaultmapClause::ImplicitBehavior::None) {
+              if (DefaultMapCategoryMatchesSymbol(defaults.first, *found)) {
+                if (!IsObjectWithDSA(*symbol)) {
+                  context_.Say(name.source,
+                      "The DEFAULTMAP(NONE) clause requires that '%s' must be "
+                      "listed in a "
+                      "data-sharing attribute, data-mapping attribute, or is_device_ptr clause"_err_en_US,
+                      symbol->name());
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+
----------------
agozillon wrote:

Sounds good @kparzysz thank you very much. I'm a little sparse on knowledge for it myself, other than having worked with this segment of code a little bit when adding the implicit firstprivate DSA, from what I recollect the segment directly after this applies implicit DSA's (firstprivate etc.), but we don't mark every implicitly applied DSA with implicit, if this was fixed I imagine moving both the defaultmap/default segments to check-omp-structure would be fairly easy (if it isn't already and I'm overthinking it) as we could just check if the DSA's are implicitly generated and error out if they are. I recall there being an issue that the implicit flag was tied to some other CodeGen related things, making it not quite possible to tag everything that's implicit with it currently. Perhaps a new flag could be used in its place but that doesn't seem like the most elegant solution.

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


More information about the flang-commits mailing list