[flang-commits] [flang] [flang][OpenACC] Relax COMMON block usage restriction in OpenACC directives (PR #162659)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Fri Oct 17 08:31:22 PDT 2025


================
@@ -189,7 +189,29 @@ class Scope {
   mapType &commonBlocks() { return commonBlocks_; }
   const mapType &commonBlocks() const { return commonBlocks_; }
   Symbol &MakeCommonBlock(SourceName, SourceName location);
-  Symbol *FindCommonBlock(const SourceName &) const;
+  bool AddCommonBlockUse(const SourceName &name, Symbol &cbSymbol);
+  mapType &commonBlockUses() { return commonBlockUses_; }
+
+  // Find COMMON block that is not USE-associated in the current scope
+  Symbol *FindCommonBlock(const SourceName &name) const {
+    if (const auto it{commonBlocks_.find(name)}; it != commonBlocks_.end()) {
+      return &*it->second;
+    }
+    return nullptr;
+  }
+
+  // Find USE-associated COMMON block in the current scope
+  Symbol *FindCommonBlockUse(const SourceName &name) const {
+    if (const auto it{commonBlockUses_.find(name)};
+        it != commonBlockUses_.end()) {
+      return &*it->second;
+    }
+    return nullptr;
+  }
+
+  // Find COMMON block in current and surrounding scopes, follow USE
+  // associations
+  Symbol *FindCommonBlockInSurroundingScopes(const SourceName &) const;
----------------
eugeneepshteyn wrote:

I went with `FindCommonBlockInVisibleScopes()`

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


More information about the flang-commits mailing list