[flang-commits] [flang] 441a725 - [Flang][OpenMP] Fix false positive common block error in LINEAR clause (#189170)
via flang-commits
flang-commits at lists.llvm.org
Fri Jun 5 07:10:25 PDT 2026
Author: Aditya Trivedi
Date: 2026-06-05T11:10:20-03:00
New Revision: 441a7255e97c8198988b66ad7e15ab69051ed358
URL: https://github.com/llvm/llvm-project/commit/441a7255e97c8198988b66ad7e15ab69051ed358
DIFF: https://github.com/llvm/llvm-project/commit/441a7255e97c8198988b66ad7e15ab69051ed358.diff
LOG: [Flang][OpenMP] Fix false positive common block error in LINEAR clause (#189170)
Fixes #184923
Added:
Modified:
flang/lib/Semantics/check-omp-loop.cpp
flang/lib/Semantics/check-omp-structure.cpp
flang/test/Semantics/OpenMP/linear-clause01.f90
flang/test/Semantics/OpenMP/simd-aligned.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-omp-loop.cpp b/flang/lib/Semantics/check-omp-loop.cpp
index 6c816d71b35a8..41f6835252665 100644
--- a/flang/lib/Semantics/check-omp-loop.cpp
+++ b/flang/lib/Semantics/check-omp-loop.cpp
@@ -819,9 +819,9 @@ 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,
+ "'%s' is a common block name and must not appear in a LINEAR clause"_err_en_US,
symbol->name());
}
}
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index b88fec7941456..b6d64475c6c77 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -736,7 +736,7 @@ void OmpStructureChecker::CheckMultListItems() {
for (const auto &ompObject : alignedList.v) {
if (const auto *name{parser::Unwrap<parser::Name>(ompObject)}) {
if (name->symbol) {
- if (FindCommonBlockContaining(*(name->symbol))) {
+ if (name->symbol->has<CommonBlockDetails>()) {
context_.Say(clause->source,
"'%s' is a common block name and can not appear in an "
"ALIGNED clause"_err_en_US,
diff --git a/flang/test/Semantics/OpenMP/linear-clause01.f90 b/flang/test/Semantics/OpenMP/linear-clause01.f90
index 63b09c07875e5..2132ed31a7321 100644
--- a/flang/test/Semantics/OpenMP/linear-clause01.f90
+++ b/flang/test/Semantics/OpenMP/linear-clause01.f90
@@ -44,6 +44,8 @@ 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)
+
+ !ERROR: 'cc' is a common block name and must not appear in a LINEAR clause
+ !$omp declare simd linear(/cc/)
end subroutine linear_clause_03
diff --git a/flang/test/Semantics/OpenMP/simd-aligned.f90 b/flang/test/Semantics/OpenMP/simd-aligned.f90
index a1c5da1f5bc5c..14e88c7698e77 100644
--- a/flang/test/Semantics/OpenMP/simd-aligned.f90
+++ b/flang/test/Semantics/OpenMP/simd-aligned.f90
@@ -52,13 +52,20 @@ program omp_simd
print *, a
- !ERROR: 'c' is a common block name and can not appear in an ALIGNED clause
+ !ERROR: 'c' in ALIGNED clause must be of type C_PTR, POINTER or ALLOCATABLE
!$omp simd aligned(c)
do i = 1, 10
c = 5
end do
!$omp end simd
+ !ERROR: 'cmn' is a common block name and can not appear in an ALIGNED clause
+ !$omp simd aligned(/cmn/)
+ do i = 1, 10
+ c = 5
+ end do
+ !$omp end simd
+
!ERROR: 'd' in ALIGNED clause must be of type C_PTR, POINTER or ALLOCATABLE
!WARNING: Alignment is not a power of 2, Aligned clause will be ignored [-Wopenmp-usage]
!$omp simd aligned(d:100)
More information about the flang-commits
mailing list