[flang-commits] [flang] [flang][OpenMP] Fix the detection of static storage duration variables (PR #227871)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Mon Oct 5 08:46:19 PDT 2026


================
@@ -414,12 +414,7 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
 
   static bool HasStaticStorageDuration(const Symbol &symbol) {
     auto &ultSym = symbol.GetUltimate();
-    // Module-scope variable
-    return ultSym.owner().kind() == Scope::Kind::Module ||
-        // Data statement variable
-        ultSym.flags().test(Symbol::Flag::InDataStmt) ||
-        // Save attribute variable
-        ultSym.attrs().test(Attr::SAVE) ||
+    return IsSaved(ultSym) ||
----------------
eugeneepshteyn wrote:

Could you please check, whether BLOCK variables do the right thing now?
```fortran
subroutine s()
  !$omp parallel default(private)
  block
    integer :: cnt = 0
    cnt = cnt + 1
  end block
  !$omp end parallel
end subroutine
```
(And please add BLOCK tests.)

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


More information about the flang-commits mailing list