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

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Thu Oct 16 13:05:48 PDT 2025


================
@@ -3627,6 +3627,28 @@ void ModuleVisitor::Post(const parser::UseStmt &x) {
       }
     }
   }
+  // Go through the list of COMMON block symbols in the module scope and add
+  // their USE association to the current scope's USE-associated COMMON blocks.
+  for (const auto &[name, symbol] : useModuleScope_->commonBlocks()) {
+    if (Symbol *localCB{currScope().FindCommonBlockInSurroundingScopes(name)};
+        !localCB) {
+      // Make a symbol, but don't add it to the Scope, since it needs to
+      // be added to the USE-associated COMMON blocks
+      localCB = &currScope().MakeSymbol(
+          name, symbol->attrs(), UseDetails{name, symbol->GetUltimate()});
+      currScope().AddCommonBlockUse(name, *localCB);
+    }
+  }
+  // Go through the list of USE-associated COMMON block symbols in the module
+  // scope and add USE associations to their ultimate symbols to the current
+  // scope's USE-associated COMMON blocks.
+  for (const auto &[name, symbol] : useModuleScope_->commonBlockUses()) {
+    // Make a symbol, but don't add it to the Scope, since it needs to
+    // be added to the USE-associated COMMON blocks
+    Symbol *localCB = &currScope().MakeSymbol(
----------------
klausler wrote:

Please use braced initialization outside of lowering.

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


More information about the flang-commits mailing list