[flang-commits] [flang] 6893d27 - [flang][acc] Improve clause validity check around do concurrent (#184389)
via flang-commits
flang-commits at lists.llvm.org
Tue Mar 3 11:03:05 PST 2026
Author: Razvan Lupusoru
Date: 2026-03-03T11:03:01-08:00
New Revision: 6893d277575df9779184cb1b2a1efea31dc0a65c
URL: https://github.com/llvm/llvm-project/commit/6893d277575df9779184cb1b2a1efea31dc0a65c
DIFF: https://github.com/llvm/llvm-project/commit/6893d277575df9779184cb1b2a1efea31dc0a65c.diff
LOG: [flang][acc] Improve clause validity check around do concurrent (#184389)
The current validity message prints out both "TILE" and "COLLAPSE" even
if just one of them is used. This makes it confusing if the user only
used one of them. This improves the messages to be precise which clause
is not allowed (and separate messages are issued when both clauses are
used).
Added:
Modified:
flang/lib/Semantics/canonicalize-acc.cpp
flang/test/Semantics/OpenACC/acc-canonicalization-validity.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/canonicalize-acc.cpp b/flang/lib/Semantics/canonicalize-acc.cpp
index 108fd33c2ed94..11be484f66621 100644
--- a/flang/lib/Semantics/canonicalize-acc.cpp
+++ b/flang/lib/Semantics/canonicalize-acc.cpp
@@ -98,10 +98,14 @@ class CanonicalizationOfAcc {
const auto &accClauseList =
std::get<parser::AccClauseList>(beginLoopDirective.t);
for (const auto &clause : accClauseList.v) {
- if (std::holds_alternative<parser::AccClause::Collapse>(clause.u) ||
- std::holds_alternative<parser::AccClause::Tile>(clause.u)) {
+ if (std::holds_alternative<parser::AccClause::Tile>(clause.u)) {
messages_.Say(beginLoopDirective.source,
- "TILE and COLLAPSE clause may not appear on loop construct "
+ "TILE clause may not appear on loop construct "
+ "associated with DO CONCURRENT"_err_en_US);
+ }
+ if (std::holds_alternative<parser::AccClause::Collapse>(clause.u)) {
+ messages_.Say(beginLoopDirective.source,
+ "COLLAPSE clause may not appear on loop construct "
"associated with DO CONCURRENT"_err_en_US);
}
}
diff --git a/flang/test/Semantics/OpenACC/acc-canonicalization-validity.f90 b/flang/test/Semantics/OpenACC/acc-canonicalization-validity.f90
index ced7dd46803ee..c0eab1f3f9181 100644
--- a/flang/test/Semantics/OpenACC/acc-canonicalization-validity.f90
+++ b/flang/test/Semantics/OpenACC/acc-canonicalization-validity.f90
@@ -85,7 +85,7 @@ program openacc_clause_validity
end do
!$acc parallel
- !ERROR: TILE and COLLAPSE clause may not appear on loop construct associated with DO CONCURRENT
+ !ERROR: COLLAPSE clause may not appear on loop construct associated with DO CONCURRENT
!$acc loop collapse(2)
do concurrent (i = 1:N, j = 1:N)
aa(i, j) = 3.14
@@ -93,11 +93,20 @@ program openacc_clause_validity
!$acc end parallel
!$acc parallel
- !ERROR: TILE and COLLAPSE clause may not appear on loop construct associated with DO CONCURRENT
+ !ERROR: TILE clause may not appear on loop construct associated with DO CONCURRENT
!$acc loop tile(2, 2)
do concurrent (i = 1:N, j = 1:N)
aa(i, j) = 3.14
end do
!$acc end parallel
+ !$acc parallel
+ !ERROR: TILE clause may not appear on loop construct associated with DO CONCURRENT
+ !ERROR: COLLAPSE clause may not appear on loop construct associated with DO CONCURRENT
+ !$acc loop tile(2, 2) collapse(2)
+ do concurrent (i = 1:N, j = 1:N)
+ aa(i, j) = 3.14
+ end do
+ !$acc end parallel
+
end program openacc_clause_validity
More information about the flang-commits
mailing list