Skip to content

Commit ccac456

Browse files
author
git apple-llvm automerger
committed
Merge commit 'a0839c13fd32' from llvm.org/main into next
2 parents 0dd0d1c + a0839c1 commit ccac456

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8804,6 +8804,9 @@ static bool checkOpenMPIterationSpace(
88048804
}
88058805
assert(((For && For->getBody()) || (CXXFor && CXXFor->getBody())) &&
88068806
"No loop body.");
8807+
// Postpone analysis in dependent contexts for ranged for loops.
8808+
if (CXXFor && SemaRef.CurContext->isDependentContext())
8809+
return false;
88078810

88088811
OpenMPIterationSpaceChecker ISC(SemaRef, SupportsNonRectangular, DSA,
88098812
For ? For->getForLoc() : CXXFor->getForLoc());

clang/test/OpenMP/for_loop_auto.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -ast-print -std=c++20 %s -Wsign-conversion | FileCheck %s
2+
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++20 -emit-pch -o %t %s
3+
// RUN: %clang_cc1 -fopenmp -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
4+
5+
// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print -std=c++20 %s -Wsign-conversion | FileCheck %s
6+
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++20 -emit-pch -o %t %s
7+
// RUN: %clang_cc1 -fopenmp-simd -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
8+
// expected-no-diagnostics
9+
10+
#ifndef HEADER
11+
#define HEADER
12+
13+
// CHECK: template <> void do_loop(const auto &v) {
14+
// CHECK-NEXT: #pragma omp parallel for
15+
// CHECK-NEXT: for (const auto &i : v)
16+
// CHECK-NEXT: ;
17+
// CHECK-NEXT: }
18+
19+
void do_loop(const auto &v) {
20+
#pragma omp parallel for
21+
for (const auto &i : v)
22+
;
23+
}
24+
#endif

0 commit comments

Comments
 (0)