Skip to content

Commit 5f168ad

Browse files
committed
[Clang][OpenMP] Fix the wrong transform of num_teams claused introduced in #99732
1 parent 8c4e039 commit 5f168ad

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

clang/lib/Sema/TreeTransform.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11018,11 +11018,16 @@ TreeTransform<Derived>::TransformOMPAllocateClause(OMPAllocateClause *C) {
1101811018
template <typename Derived>
1101911019
OMPClause *
1102011020
TreeTransform<Derived>::TransformOMPNumTeamsClause(OMPNumTeamsClause *C) {
11021-
ExprResult E = getDerived().TransformExpr(C->getNumTeams().front());
11022-
if (E.isInvalid())
11023-
return nullptr;
11021+
llvm::SmallVector<Expr *, 3> Vars;
11022+
Vars.reserve(C->varlist_size());
11023+
for (auto *VE : C->varlist()) {
11024+
ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11025+
if (EVar.isInvalid())
11026+
return nullptr;
11027+
Vars.push_back(EVar.get());
11028+
}
1102411029
return getDerived().RebuildOMPNumTeamsClause(
11025-
E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11030+
Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
1102611031
}
1102711032

1102811033
template <typename Derived>

clang/test/OpenMP/target_teams_ast_print.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ T tmain(T argc, T *argv) {
5858
foo();
5959
#pragma omp target teams allocate(my_allocator:f) reduction(^:e, f) reduction(&& : g) uses_allocators(my_allocator(traits))
6060
foo();
61+
#pragma omp target teams ompx_bare num_teams(C, C, C) thread_limit(d*C, d*C, d*C)
62+
foo();
6163
return 0;
6264
}
6365

@@ -97,6 +99,8 @@ T tmain(T argc, T *argv) {
9799
// CHECK-NEXT: foo()
98100
// CHECK-NEXT: #pragma omp target teams allocate(my_allocator: f) reduction(^: e,f) reduction(&&: g) uses_allocators(my_allocator(traits))
99101
// CHECK-NEXT: foo()
102+
// CHECK-NEXT: #pragma omp target teams ompx_bare num_teams(1,1,1) thread_limit(d * 1,d * 1,d * 1)
103+
// CHECK-NEXT: foo();
100104

101105
enum Enum { };
102106

0 commit comments

Comments
 (0)