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

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Fri Feb 13 05:11:49 PST 2026


https://github.com/kiranchandramohan updated https://github.com/llvm/llvm-project/pull/181354

>From 4282e3c33f1667249be0b1fc155279c290bf72ed Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Thu, 12 Feb 2026 00:29:04 +0100
Subject: [PATCH] [Flang][OpenMP] Fix for threadprivate check in copyin clause

Use the ultimate symbol in the threadprivate check

Fixes #180094
---
 flang/lib/Semantics/resolve-directives.cpp          |  7 +++----
 flang/test/Semantics/OpenMP/common-block_copyin.f90 | 12 ++++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)
 create mode 100644 flang/test/Semantics/OpenMP/common-block_copyin.f90

diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 1fde0d62581e8..147a17a31b59f 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -3465,10 +3465,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