[PATCH] [OPNEMP] Fixed instantiation of 'if' clause
Alexey Bataev
a.bataev at hotmail.com
Wed Feb 19 20:51:29 PST 2014
Hi doug.gregor, hfinkel, cbergstrom, gribozavr, fraggamuffin,
http://llvm-reviews.chandlerc.com/D2837
Files:
test/OpenMP/parallel_ast_print.cpp
lib/Sema/TreeTransform.h
Index: test/OpenMP/parallel_ast_print.cpp
===================================================================
--- test/OpenMP/parallel_ast_print.cpp
+++ test/OpenMP/parallel_ast_print.cpp
@@ -9,37 +9,45 @@
void foo() {}
-template <typename T>
+template <typename T, int C>
T tmain(T argc, T *argv) {
T b = argc, c, d, e, f, g;
static T a;
#pragma omp parallel
a=2;
#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared (d) if (argc > 0)
foo();
+#pragma omp parallel if (C)
+ foo();
return 0;
}
-// CHECK: template <typename T = int> int tmain(int argc, int *argv) {
+// CHECK: template <typename T = int, int C = 2> int tmain(int argc, int *argv) {
// CHECK-NEXT: int b = argc, c, d, e, f, g;
// CHECK-NEXT: static int a;
// CHECK-NEXT: #pragma omp parallel
// CHECK-NEXT: a = 2;
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0)
// CHECK-NEXT: foo()
-// CHECK: template <typename T = float> float tmain(float argc, float *argv) {
+// CHECK-NEXT: #pragma omp parallel if(2)
+// CHECK-NEXT: foo()
+// CHECK: template <typename T = float, int C = 0> float tmain(float argc, float *argv) {
// CHECK-NEXT: float b = argc, c, d, e, f, g;
// CHECK-NEXT: static float a;
// CHECK-NEXT: #pragma omp parallel
// CHECK-NEXT: a = 2;
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0)
// CHECK-NEXT: foo()
-// CHECK: template <typename T> T tmain(T argc, T *argv) {
+// CHECK-NEXT: #pragma omp parallel if(0)
+// CHECK-NEXT: foo()
+// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
// CHECK-NEXT: T b = argc, c, d, e, f, g;
// CHECK-NEXT: static T a;
// CHECK-NEXT: #pragma omp parallel
// CHECK-NEXT: a = 2;
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0)
// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp parallel if(C)
+// CHECK-NEXT: foo()
int main (int argc, char **argv) {
float x;
@@ -54,7 +62,7 @@
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) if(argc > 0)
foo();
// CHECK-NEXT: foo();
- return tmain(b, &b) + tmain(x, &x);
+ return tmain<int, 2>(b, &b) + tmain<float, 0>(x, &x);
}
#endif
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6292,7 +6292,10 @@
template<typename Derived>
OMPClause *
TreeTransform<Derived>::TransformOMPIfClause(OMPIfClause *C) {
- return getDerived().RebuildOMPIfClause(C->getCondition(), C->getLocStart(),
+ ExprResult Cond = getDerived().TransformExpr(C->getCondition());
+ if (Cond.isInvalid())
+ return 0;
+ return getDerived().RebuildOMPIfClause(Cond.take(), C->getLocStart(),
C->getLParenLoc(), C->getLocEnd());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2837.1.patch
Type: text/x-patch
Size: 2927 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140219/334f514a/attachment.bin>
More information about the cfe-commits
mailing list