[llvm-branch-commits] [cfe-branch] r318116 - Merging r313675:
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Nov 13 15:52:05 PST 2017
Author: tstellar
Date: Mon Nov 13 15:52:05 2017
New Revision: 318116
URL: http://llvm.org/viewvc/llvm-project?rev=318116&view=rev
Log:
Merging r313675:
------------------------------------------------------------------------
r313675 | rcraik | 2017-09-19 14:04:23 -0700 (Tue, 19 Sep 2017) | 9 lines
[OpenMP] fix seg-faults printing diagnostics with invalid ordered(n) values
When the value specified for n in ordered(n) is larger than the number of loops a segmentation fault can occur in one of two ways when attempting to print out a diagnostic for an associated depend(sink : vec):
1) The iteration vector vec contains less than n items
2) The iteration vector vec contains a variable that is not a loop control variable
This patch addresses both of these issues.
Differential Revision: https://reviews.llvm.org/D38049
------------------------------------------------------------------------
Modified:
cfe/branches/release_50/include/clang/Basic/DiagnosticSemaKinds.td
cfe/branches/release_50/lib/Sema/SemaOpenMP.cpp
cfe/branches/release_50/test/OpenMP/ordered_messages.cpp
Modified: cfe/branches/release_50/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/include/clang/Basic/DiagnosticSemaKinds.td?rev=318116&r1=318115&r2=318116&view=diff
==============================================================================
--- cfe/branches/release_50/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/release_50/include/clang/Basic/DiagnosticSemaKinds.td Mon Nov 13 15:52:05 2017
@@ -8830,7 +8830,7 @@ def err_omp_firstprivate_distribute_in_t
def err_omp_depend_clause_thread_simd : Error<
"'depend' clauses cannot be mixed with '%0' clause">;
def err_omp_depend_sink_expected_loop_iteration : Error<
- "expected %0 loop iteration variable">;
+ "expected%select{| %1}0 loop iteration variable">;
def err_omp_depend_sink_unexpected_expr : Error<
"unexpected expression: number of expressions is larger than the number of associated loops">;
def err_omp_depend_sink_expected_plus_minus : Error<
Modified: cfe/branches/release_50/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Sema/SemaOpenMP.cpp?rev=318116&r1=318115&r2=318116&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/branches/release_50/lib/Sema/SemaOpenMP.cpp Mon Nov 13 15:52:05 2017
@@ -10227,9 +10227,14 @@ Sema::ActOnOpenMPDependClause(OpenMPDepe
if (!CurContext->isDependentContext() &&
DSAStack->getParentOrderedRegionParam() &&
DepCounter != DSAStack->isParentLoopControlVariable(D).first) {
- Diag(ELoc, diag::err_omp_depend_sink_expected_loop_iteration)
- << DSAStack->getParentLoopControlVariable(
- DepCounter.getZExtValue());
+ ValueDecl* VD = DSAStack->getParentLoopControlVariable(
+ DepCounter.getZExtValue());
+ if (VD) {
+ Diag(ELoc, diag::err_omp_depend_sink_expected_loop_iteration)
+ << 1 << VD;
+ } else {
+ Diag(ELoc, diag::err_omp_depend_sink_expected_loop_iteration) << 0;
+ }
continue;
}
OpsOffs.push_back({RHS, OOK});
@@ -10259,8 +10264,9 @@ Sema::ActOnOpenMPDependClause(OpenMPDepe
if (!CurContext->isDependentContext() && DepKind == OMPC_DEPEND_sink &&
TotalDepCount > VarList.size() &&
- DSAStack->getParentOrderedRegionParam()) {
- Diag(EndLoc, diag::err_omp_depend_sink_expected_loop_iteration)
+ DSAStack->getParentOrderedRegionParam() &&
+ DSAStack->getParentLoopControlVariable(VarList.size() + 1)) {
+ Diag(EndLoc, diag::err_omp_depend_sink_expected_loop_iteration) << 1
<< DSAStack->getParentLoopControlVariable(VarList.size() + 1);
}
if (DepKind != OMPC_DEPEND_source && DepKind != OMPC_DEPEND_sink &&
Modified: cfe/branches/release_50/test/OpenMP/ordered_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/test/OpenMP/ordered_messages.cpp?rev=318116&r1=318115&r2=318116&view=diff
==============================================================================
--- cfe/branches/release_50/test/OpenMP/ordered_messages.cpp (original)
+++ cfe/branches/release_50/test/OpenMP/ordered_messages.cpp Mon Nov 13 15:52:05 2017
@@ -270,5 +270,13 @@ int k;
}
}
+#pragma omp for ordered(2) // expected-note {{as specified in 'ordered' clause}}
+ for (int i = 0; i < 10; ++i) { // expected-error {{expected 2 for loops after '#pragma omp for', but found only 1}}
+#pragma omp ordered depend(sink : i)
+ int j;
+#pragma omp ordered depend(sink : i, j) // expected-error {{expected loop iteration variable}}
+ foo();
+ }
+
return foo<int>(); // expected-note {{in instantiation of function template specialization 'foo<int>' requested here}}
}
More information about the llvm-branch-commits
mailing list