davidsh created this revision. davidsh added reviewers: carlo.bertolli, arpith-jacob, kkwli0, sfantao, ABataev. davidsh added a subscriber: cfe-commits.
#pragma omp for { for(...) } This is technically not allowed by the standard, gcc doesnt allow such code. https://reviews.llvm.org/D24615 Files: lib/Sema/SemaOpenMP.cpp test/OpenMP/for_loop_messages.cpp Index: test/OpenMP/for_loop_messages.cpp =================================================================== --- test/OpenMP/for_loop_messages.cpp +++ test/OpenMP/for_loop_messages.cpp @@ -353,6 +353,14 @@ } #pragma omp parallel +// expected-error@+2 {{statement after '#pragma omp for' must be a for loop}} +#pragma omp for + { + for (int i = 0; i < 16; ++i) + ; + } + +#pragma omp parallel // expected-note@+3 {{loop step is expected to be positive due to this condition}} // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}} #pragma omp for Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -5133,7 +5133,9 @@ llvm::MapVector<Expr *, DeclRefExpr *> Captures; SmallVector<LoopIterationSpace, 4> IterSpaces; IterSpaces.resize(NestedLoopCount); - Stmt *CurStmt = AStmt->IgnoreContainers(/* IgnoreCaptured */ true); + Stmt *CurStmt = AStmt; + if (auto CapS = dyn_cast_or_null<CapturedStmt>(CurStmt)) + CurStmt = CapS->getCapturedStmt(); for (unsigned Cnt = 0; Cnt < NestedLoopCount; ++Cnt) { if (CheckOpenMPIterationSpace(DKind, CurStmt, SemaRef, DSA, Cnt, NestedLoopCount, CollapseLoopCountExpr,
Index: test/OpenMP/for_loop_messages.cpp =================================================================== --- test/OpenMP/for_loop_messages.cpp +++ test/OpenMP/for_loop_messages.cpp @@ -353,6 +353,14 @@ } #pragma omp parallel +// expected-error@+2 {{statement after '#pragma omp for' must be a for loop}} +#pragma omp for + { + for (int i = 0; i < 16; ++i) + ; + } + +#pragma omp parallel // expected-note@+3 {{loop step is expected to be positive due to this condition}} // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}} #pragma omp for Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -5133,7 +5133,9 @@ llvm::MapVector<Expr *, DeclRefExpr *> Captures; SmallVector<LoopIterationSpace, 4> IterSpaces; IterSpaces.resize(NestedLoopCount); - Stmt *CurStmt = AStmt->IgnoreContainers(/* IgnoreCaptured */ true); + Stmt *CurStmt = AStmt; + if (auto CapS = dyn_cast_or_null<CapturedStmt>(CurStmt)) + CurStmt = CapS->getCapturedStmt(); for (unsigned Cnt = 0; Cnt < NestedLoopCount; ++Cnt) { if (CheckOpenMPIterationSpace(DKind, CurStmt, SemaRef, DSA, Cnt, NestedLoopCount, CollapseLoopCountExpr,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits