diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2015-12-28 06:23:08 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2015-12-28 06:23:08 +0000 |
| commit | 993d28073c1bef2eaabf815523157bcc6e0ddd47 (patch) | |
| tree | c93d4e50b376b671fcb813e73f297d542ab22168 | |
| parent | af88afb214f04cffbaf760956c31855c7b845593 (diff) | |
| download | bcm5719-llvm-993d28073c1bef2eaabf815523157bcc6e0ddd47.tar.gz bcm5719-llvm-993d28073c1bef2eaabf815523157bcc6e0ddd47.zip | |
[OPENMP 4.5] Do not allow 'linear' clause along with 'ordered(expr)' clause.
According to OpenMP 4.5 "A linear clause or an ordered clause with a parameter can be specified on a loop directive but not both.""
llvm-svn: 256485
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 15 | ||||
| -rw-r--r-- | clang/test/OpenMP/for_ast_print.cpp | 4 | ||||
| -rw-r--r-- | clang/test/OpenMP/for_linear_messages.cpp | 4 | ||||
| -rw-r--r-- | clang/test/OpenMP/parallel_for_ast_print.cpp | 4 |
5 files changed, 25 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index d4c77de089e..6718d89d9f0 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -7961,6 +7961,8 @@ def err_omp_depend_sink_expected_plus_minus : Error< "expected '+' or '-' operation">; def err_omp_depend_sink_source_not_allowed : Error< "'depend(%select{source|sink:vec}0)' clause%select{|s}0 cannot be mixed with 'depend(%select{sink:vec|source}0)' clause%select{s|}0">; +def err_omp_linear_ordered : Error< + "'linear' clause cannot be specified along with 'ordered' clause with a parameter">; } // end of OpenMP category let CategoryName = "Related Result Type Issue" in { diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index c42718d576b..5aa1fcb184b 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -1622,6 +1622,9 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, ActOnCapturedRegionError(); return StmtError(); } + + OMPOrderedClause *OC = nullptr; + SmallVector<OMPLinearClause *, 4> LCs; // This is required for proper codegen. for (auto *Clause : Clauses) { if (isOpenMPPrivate(Clause->getClauseKind()) || @@ -1647,6 +1650,18 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S, MarkDeclarationsReferencedInExpr(E); } } + if (Clause->getClauseKind() == OMPC_ordered) + OC = cast<OMPOrderedClause>(Clause); + else if (Clause->getClauseKind() == OMPC_linear) + LCs.push_back(cast<OMPLinearClause>(Clause)); + } + if (!LCs.empty() && OC && OC->getNumForLoops()) { + for (auto *C : LCs) { + Diag(C->getLocStart(), diag::err_omp_linear_ordered) + << SourceRange(OC->getLocStart(), OC->getLocEnd()); + } + ActOnCapturedRegionError(); + return StmtError(); } return ActOnCapturedRegionEnd(S.get()); } diff --git a/clang/test/OpenMP/for_ast_print.cpp b/clang/test/OpenMP/for_ast_print.cpp index 1af391d2cf6..8fd82e7f028 100644 --- a/clang/test/OpenMP/for_ast_print.cpp +++ b/clang/test/OpenMP/for_ast_print.cpp @@ -20,7 +20,7 @@ T tmain(T argc) { // CHECK-NEXT: for (int i = 0; i < 2; ++i) // CHECK-NEXT: a = 2; #pragma omp parallel -#pragma omp for private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered(N) nowait linear(a : N) +#pragma omp for private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered(N) nowait for (int i = 0; i < 2; ++i) for (int j = 0; j < 2; ++j) for (int j = 0; j < 2; ++j) @@ -33,7 +33,7 @@ T tmain(T argc) { for (int j = 0; j < 2; ++j) foo(); // CHECK-NEXT: #pragma omp parallel - // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) nowait linear(a: N) + // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) nowait // CHECK-NEXT: for (int i = 0; i < 2; ++i) // CHECK-NEXT: for (int j = 0; j < 2; ++j) // CHECK-NEXT: for (int j = 0; j < 2; ++j) diff --git a/clang/test/OpenMP/for_linear_messages.cpp b/clang/test/OpenMP/for_linear_messages.cpp index b06852e2ab7..39fb21ef7be 100644 --- a/clang/test/OpenMP/for_linear_messages.cpp +++ b/clang/test/OpenMP/for_linear_messages.cpp @@ -145,6 +145,8 @@ template<class I, class C> int foomain(I argc, C **argv) { for (int k = 0; k < argc; ++k) { ++k; v += j; } #pragma omp for linear(i) for (int k = 0; k < argc; ++k) ++k; + #pragma omp for linear(i) ordered(1) // expected-error {{'linear' clause cannot be specified along with 'ordered' clause with a parameter}} + for (int k = 0; k < argc; ++k) ++k; return 0; } @@ -207,6 +209,8 @@ int main(int argc, char **argv) { for (int k = 0; k < argc; ++k) ++k; #pragma omp for linear(i) for (int k = 0; k < argc; ++k) ++k; + #pragma omp for linear(i) ordered(1) // expected-error {{'linear' clause cannot be specified along with 'ordered' clause with a parameter}} + for (int k = 0; k < argc; ++k) ++k; foomain<int,char>(argc,argv); return 0; diff --git a/clang/test/OpenMP/parallel_for_ast_print.cpp b/clang/test/OpenMP/parallel_for_ast_print.cpp index 197cd0fe3f1..c4be521455d 100644 --- a/clang/test/OpenMP/parallel_for_ast_print.cpp +++ b/clang/test/OpenMP/parallel_for_ast_print.cpp @@ -21,7 +21,7 @@ T tmain(T argc) { a = 2; // CHECK-NEXT: for (int i = 0; i < 2; ++i) // CHECK-NEXT: a = 2; -#pragma omp parallel for private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered(N) if (parallel :argc) num_threads(N) default(shared) shared(e) reduction(+ : h) linear(a:N) +#pragma omp parallel for private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered(N) if (parallel :argc) num_threads(N) default(shared) shared(e) reduction(+ : h) for (int i = 0; i < 2; ++i) for (int j = 0; j < 2; ++j) for (int j = 0; j < 2; ++j) @@ -33,7 +33,7 @@ T tmain(T argc) { for (int j = 0; j < 2; ++j) for (int j = 0; j < 2; ++j) foo(); - // CHECK-NEXT: #pragma omp parallel for private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h) linear(a: N) + // CHECK-NEXT: #pragma omp parallel for private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h) // CHECK-NEXT: for (int i = 0; i < 2; ++i) // CHECK-NEXT: for (int j = 0; j < 2; ++j) // CHECK-NEXT: for (int j = 0; j < 2; ++j) |

