[flang-commits] [flang] [Flang][OpenMP][Sema] Add OpenMP warning when mapping local descriptors to device on enter without a corresponding exit (PR #201060)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Mon Jun 8 06:44:35 PDT 2026


================
@@ -142,7 +141,35 @@ void OmpStructureChecker::Enter(const parser::SubroutineStmt &x) {
   scopeStack_.push_back(sym->scope());
 }
 
+void OmpStructureChecker::CheckTempDescriptorMappings() {
+  unsigned version{context_.langOptions().OpenMPVersion};
+  for (const auto &[symbol, source] : tempDescriptorEnterMaps_) {
+    if (tempDescriptorExitMaps_.find(symbol) == tempDescriptorExitMaps_.end()) {
+      if (version >= 61) {
+        context_.Warn(common::UsageWarning::OpenMPUsage, source,
+            "The map of '%s' may include a descriptor that is created locally. "
+            "Mapping this descriptor without an appropriate TARGET EXIT DATA "
+            "in the same scope may result in the device retaining an invalid "
+            "descriptor reference. To avoid mapping the descriptor utilize "
+            "OpenMP's ref_ptee reference modifier to map just the "
+            "data"_warn_en_US,
----------------
kparzysz wrote:

We usually keep message strings unbroken (allowing them to exceed 80 columns) to make it easier to grep for the contents.

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


More information about the flang-commits mailing list