[flang-commits] [flang] [Flang][OpenMP] Fix false positive common block error in LINEAR clause (PR #189170)
Aditya Trivedi via flang-commits
flang-commits at lists.llvm.org
Sat Mar 28 08:37:25 PDT 2026
https://github.com/adit4443ya created https://github.com/llvm/llvm-project/pull/189170
Fixes #184923
CC: @kparzysz @ohno-fj
>From 9fcb81cfff97e09290663329d2007dadf2ecf43b Mon Sep 17 00:00:00 2001
From: Aditya Trivedi <adit4443ya at gmail.com>
Date: Sat, 28 Mar 2026 15:33:41 +0000
Subject: [PATCH] [Flang][OpenMP] Fix false positive common block error in
LINEAR clause
The check for common block names in the OpenMP LINEAR clause previously
used FindCommonBlockContaining, which incorrectly flagged any variable
that was a member of a common block as violating the restriction that
a common block name cannot appear in a LINEAR clause.
This updates the check to correctly verify whether the symbol itself
has CommonBlockDetails.
---
flang/lib/Semantics/check-omp-loop.cpp | 2 +-
flang/test/Semantics/OpenMP/linear-clause01.f90 | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/flang/lib/Semantics/check-omp-loop.cpp b/flang/lib/Semantics/check-omp-loop.cpp
index e35e83e5b191b..9f3858784860f 100644
--- a/flang/lib/Semantics/check-omp-loop.cpp
+++ b/flang/lib/Semantics/check-omp-loop.cpp
@@ -750,7 +750,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Linear &x) {
"The list item `%s` in a LINEAR clause must not be Cray Pointer or a variable with POINTER attribute"_err_en_US,
symbol->name());
}
- if (FindCommonBlockContaining(*symbol)) {
+ if (symbol->has<CommonBlockDetails>()) {
context_.Say(source,
"'%s' is a common block name and must not appear in an LINEAR clause"_err_en_US,
symbol->name());
diff --git a/flang/test/Semantics/OpenMP/linear-clause01.f90 b/flang/test/Semantics/OpenMP/linear-clause01.f90
index 63b09c07875e5..60a8ade1c954c 100644
--- a/flang/test/Semantics/OpenMP/linear-clause01.f90
+++ b/flang/test/Semantics/OpenMP/linear-clause01.f90
@@ -44,6 +44,5 @@ subroutine linear_clause_03(arg)
integer :: i
common /cc/ i
!ERROR: The list item `i` must be a dummy argument
- !ERROR: 'i' is a common block name and must not appear in an LINEAR clause
!$omp declare simd linear(i)
end subroutine linear_clause_03
More information about the flang-commits
mailing list