Skip to content

Commit

Permalink
[OPENMP]Fix datasharing checks for if clause in parallel taskloop
Browse files Browse the repository at this point in the history
directives.

If the default datasharing is set to none, the datasharing attributes
for variables in the condition of the if clause for the inner taskloop
  directive must be verified.
  • Loading branch information
alexey-bataev committed Nov 21, 2019
1 parent 4ae0a13 commit 77d049d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
10 changes: 7 additions & 3 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4766,13 +4766,17 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
case OMPC_num_threads:
case OMPC_dist_schedule:
// Do not analyse if no parent teams directive.
if (isOpenMPTeamsDirective(DSAStack->getCurrentDirective()))
if (isOpenMPTeamsDirective(Kind))
break;
continue;
case OMPC_if:
if (isOpenMPTeamsDirective(DSAStack->getCurrentDirective()) &&
if (isOpenMPTeamsDirective(Kind) &&
cast<OMPIfClause>(C)->getNameModifier() != OMPD_target)
break;
if (isOpenMPParallelDirective(Kind) &&
isOpenMPTaskLoopDirective(Kind) &&
cast<OMPIfClause>(C)->getNameModifier() != OMPD_parallel)
break;
continue;
case OMPC_schedule:
break;
Expand All @@ -4781,7 +4785,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
case OMPC_final:
case OMPC_priority:
// Do not analyze if no parent parallel directive.
if (isOpenMPParallelDirective(DSAStack->getCurrentDirective()))
if (isOpenMPParallelDirective(Kind))
break;
continue;
case OMPC_ordered:
Expand Down
10 changes: 10 additions & 0 deletions clang/test/OpenMP/parallel_master_taskloop_loop_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,19 @@ void test_loop_eh() {

void test_loop_firstprivate_lastprivate() {
S s(4);
int c;
#pragma omp parallel
#pragma omp parallel master taskloop lastprivate(s) firstprivate(s)
for (int i = 0; i < 16; ++i)
;
#pragma omp parallel master taskloop if(c) default(none) // expected-error {{variable 'c' must have explicitly specified data sharing attributes}} expected-note {{explicit data sharing attribute requested here}}
for (int i = 0; i < 16; ++i)
;
#pragma omp parallel master taskloop if(taskloop:c) default(none) // expected-error {{variable 'c' must have explicitly specified data sharing attributes}} expected-note {{explicit data sharing attribute requested here}}
for (int i = 0; i < 16; ++i)
;
#pragma omp parallel master taskloop if(parallel:c) default(none)
for (int i = 0; i < 16; ++i)
;
}

10 changes: 10 additions & 0 deletions clang/test/OpenMP/parallel_master_taskloop_simd_loop_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,19 @@ void test_loop_eh() {

void test_loop_firstprivate_lastprivate() {
S s(4);
int c;
#pragma omp parallel
#pragma omp parallel master taskloop simd lastprivate(s) firstprivate(s)
for (int i = 0; i < 16; ++i)
;
#pragma omp parallel master taskloop simd if(c) default(none) // expected-error {{variable 'c' must have explicitly specified data sharing attributes}} expected-note {{explicit data sharing attribute requested here}}
for (int i = 0; i < 16; ++i)
;
#pragma omp parallel master taskloop simd if(taskloop:c) default(none) // expected-error {{variable 'c' must have explicitly specified data sharing attributes}} expected-note {{explicit data sharing attribute requested here}}
for (int i = 0; i < 16; ++i)
;
#pragma omp parallel master taskloop simd if(parallel:c) default(none)
for (int i = 0; i < 16; ++i)
;
}

0 comments on commit 77d049d

Please sign in to comment.