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

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Wed Oct 7 13:53:24 PDT 2026


================
@@ -467,8 +462,7 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
     // as well even though they will have their own storage. They should be
     // considered local regardless of the status of the original symbol.
     const Symbol &actual{GetStorageOwner(symbol)};
-    return actual.owner() != scope && scope.Contains(actual.owner()) &&
-        !HasStaticStorageDuration(actual);
----------------
luporl wrote:

Yes, variables with static storage duration inside a BLOCK that is nested in an OpenMP construct will already be shared between all threads, complying with the spec.

> Variables with static storage duration that are declared in a scope inside the construct are shared.

I've run gfortran and Fujitsu testsuites and the only regression found was the issue linked above, that is a problem with the test.

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


More information about the flang-commits mailing list