Skip to content

Fix accsessing "PresentModifierLocs" array beyond its end. #73579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class DSAStackTy {
LoopControlVariablesMapTy LCVMap;
DefaultDataSharingAttributes DefaultAttr = DSA_unspecified;
SourceLocation DefaultAttrLoc;
DefaultmapInfo DefaultmapMap[OMPC_DEFAULTMAP_unknown];
DefaultmapInfo DefaultmapMap[OMPC_DEFAULTMAP_unknown + 1];
OpenMPDirectiveKind Directive = OMPD_unknown;
/// GenericLoopDirective with bind clause is mapped to other directives,
/// like for, distribute and simd. Presently, set MappedDirective to
Expand Down Expand Up @@ -3689,7 +3689,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
bool ErrorFound = false;
bool TryCaptureCXXThisMembers = false;
CapturedStmt *CS = nullptr;
const static unsigned DefaultmapKindNum = OMPC_DEFAULTMAP_pointer + 1;
const static unsigned DefaultmapKindNum = OMPC_DEFAULTMAP_unknown + 1;
llvm::SmallVector<Expr *, 4> ImplicitFirstprivate;
llvm::SmallVector<Expr *, 4> ImplicitPrivate;
llvm::SmallVector<Expr *, 4> ImplicitMap[DefaultmapKindNum][OMPC_MAP_delete];
Expand Down Expand Up @@ -6276,7 +6276,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
SmallVector<Expr *, 4> ImplicitPrivates(
DSAChecker.getImplicitPrivate().begin(),
DSAChecker.getImplicitPrivate().end());
const unsigned DefaultmapKindNum = OMPC_DEFAULTMAP_pointer + 1;
const unsigned DefaultmapKindNum = OMPC_DEFAULTMAP_unknown + 1;
SmallVector<Expr *, 4> ImplicitMaps[DefaultmapKindNum][OMPC_MAP_delete];
SmallVector<OpenMPMapModifierKind, NumberOfOMPMapClauseModifiers>
ImplicitMapModifiers[DefaultmapKindNum];
Expand Down
4 changes: 4 additions & 0 deletions clang/test/OpenMP/target_ast_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,8 @@ T tmain(T argc, T *argv) {
foo();
#pragma omp target thread_limit(C)
foo();
#pragma omp target defaultmap(present)
foo();

return 0;
}
Expand All @@ -1123,6 +1125,8 @@ T tmain(T argc, T *argv) {
// OMP51-NEXT: foo()
// OMP51-NEXT: #pragma omp target thread_limit(C)
// OMP51-NEXT: foo()
// OMP51-NEXT: #pragma omp target defaultmap(present)
// OMP51-NEXT: foo()

// OMP51-LABEL: int main(int argc, char **argv) {
int main (int argc, char **argv) {
Expand Down