[PATCH] D114560: [OPENMP]Fix PR51327: Range based for loop not working if range's type is a template.
Alexey Bataev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 2 13:34:34 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0839c13fd32: [OPENMP]Fix PR51327: Range based for loop not working if range's type is a… (authored by ABataev).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114560/new/
https://reviews.llvm.org/D114560
Files:
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/for_loop_auto.cpp
Index: clang/test/OpenMP/for_loop_auto.cpp
===================================================================
--- /dev/null
+++ clang/test/OpenMP/for_loop_auto.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print -std=c++20 %s -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print -std=c++20 %s -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK: template <> void do_loop(const auto &v) {
+// CHECK-NEXT: #pragma omp parallel for
+// CHECK-NEXT: for (const auto &i : v)
+// CHECK-NEXT: ;
+// CHECK-NEXT: }
+
+void do_loop(const auto &v) {
+#pragma omp parallel for
+ for (const auto &i : v)
+ ;
+}
+#endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===================================================================
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -8804,6 +8804,9 @@
}
assert(((For && For->getBody()) || (CXXFor && CXXFor->getBody())) &&
"No loop body.");
+ // Postpone analysis in dependent contexts for ranged for loops.
+ if (CXXFor && SemaRef.CurContext->isDependentContext())
+ return false;
OpenMPIterationSpaceChecker ISC(SemaRef, SupportsNonRectangular, DSA,
For ? For->getForLoc() : CXXFor->getForLoc());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114560.391445.patch
Type: text/x-patch
Size: 1689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211202/ca8852cd/attachment.bin>
More information about the cfe-commits
mailing list