[clang] 9186733 - [OpenACC] Fix infinite loop bug with the device_type checking
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 5 10:35:53 PDT 2025
Author: erichkeane
Date: 2025-05-05T10:35:49-07:00
New Revision: 91867337ada52fb113d3d4808b5acb5790b869ff
URL: https://github.com/llvm/llvm-project/commit/91867337ada52fb113d3d4808b5acb5790b869ff
DIFF: https://github.com/llvm/llvm-project/commit/91867337ada52fb113d3d4808b5acb5790b869ff.diff
LOG: [OpenACC] Fix infinite loop bug with the device_type checking
I noticed while writing a test that we ended up infinite looping thanks
to an early exit not correctly setting the next step of the loop.
Added:
Modified:
clang/lib/Sema/SemaOpenACCClause.cpp
clang/test/SemaOpenACC/loop-construct-collapse-clause.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaOpenACCClause.cpp b/clang/lib/Sema/SemaOpenACCClause.cpp
index 5a335352e6704..6187e0e719bb1 100644
--- a/clang/lib/Sema/SemaOpenACCClause.cpp
+++ b/clang/lib/Sema/SemaOpenACCClause.cpp
@@ -403,8 +403,10 @@ class SemaOpenACCClauseVisitor {
// There are no clauses of the current kind between these device_types, so
// continue.
- if (CurClauseKindItr == CurDevTypeItr)
+ if (CurClauseKindItr == CurDevTypeItr) {
+ PrevDeviceTypeItr = CurDevTypeItr;
continue;
+ }
// At this point, we know that this device_type region has a collapse. So
// diagnose if the two device_types have any overlap in their
diff --git a/clang/test/SemaOpenACC/loop-construct-collapse-clause.cpp b/clang/test/SemaOpenACC/loop-construct-collapse-clause.cpp
index 784e657cccb53..9a5f6347dec9f 100644
--- a/clang/test/SemaOpenACC/loop-construct-collapse-clause.cpp
+++ b/clang/test/SemaOpenACC/loop-construct-collapse-clause.cpp
@@ -572,4 +572,9 @@ void no_dupes_since_last_device_type() {
#pragma acc loop device_type(radeon) collapse(1) device_type(nvidia, radeon) collapse(2)
for(unsigned i = 0; i < 5; ++i)
for(unsigned j = 0; j < 5; ++j);
+
+ int NotConstexpr;
+ // expected-error at +1 3{{OpenACC 'collapse' clause loop count must be a constant expression}}
+#pragma acc loop collapse(NotConstexpr) device_type(radeon, nvidia) collapse(NotConstexpr) device_type(host) collapse(NotConstexpr)
+ for(unsigned j = 0; j < 5; ++j);
}
More information about the cfe-commits
mailing list