[flang-commits] [flang] 3cdb2e2 - [Flang][OpenMP] Fix for threadprivate check in copyin clause (#181354)

via flang-commits flang-commits at lists.llvm.org
Thu Feb 19 05:10:50 PST 2026


Author: Kiran Chandramohan
Date: 2026-02-19T13:10:44Z
New Revision: 3cdb2e2f5d0c943c5a07d969c0c13b1bb9341f26

URL: https://github.com/llvm/llvm-project/commit/3cdb2e2f5d0c943c5a07d969c0c13b1bb9341f26
DIFF: https://github.com/llvm/llvm-project/commit/3cdb2e2f5d0c943c5a07d969c0c13b1bb9341f26.diff

LOG: [Flang][OpenMP] Fix for threadprivate check in copyin clause (#181354)

Use the ultimate symbol in the threadprivate check

Fixes #180094

Added: 
    flang/test/Semantics/OpenMP/common-block_copyin.f90

Modified: 
    flang/lib/Semantics/resolve-directives.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index e8d3f9c98d19d..7e11be509cd02 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -3366,10 +3366,9 @@ void ResolveOmpParts(
 }
 
 static bool IsSymbolThreadprivate(const Symbol &symbol) {
-  if (const auto *details{symbol.detailsIf<HostAssocDetails>()}) {
-    return details->symbol().test(Symbol::Flag::OmpThreadprivate);
-  }
-  return symbol.test(Symbol::Flag::OmpThreadprivate);
+  const Symbol &ultimate{symbol.GetUltimate()};
+
+  return ultimate.test(Symbol::Flag::OmpThreadprivate);
 }
 
 static bool IsSymbolPrivate(const Symbol &symbol) {

diff  --git a/flang/test/Semantics/OpenMP/common-block_copyin.f90 b/flang/test/Semantics/OpenMP/common-block_copyin.f90
new file mode 100644
index 0000000000000..600ec3b5aad97
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/common-block_copyin.f90
@@ -0,0 +1,12 @@
+!RUN: %python %S/../test_errors.py %s %flang -fopenmp
+
+program main
+  common /cmn/ k1
+!$omp threadprivate(/cmn/)
+contains
+  subroutine ss1
+  k1 = 1
+!$omp parallel copyin (k1)
+!$omp end parallel
+  end subroutine ss1
+end program main


        


More information about the flang-commits mailing list