Skip to content

Commit 77d049d

Browse files
committed
[OPENMP]Fix datasharing checks for if clause in parallel taskloop
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.
1 parent 4ae0a13 commit 77d049d

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

clang/lib/Sema/SemaOpenMP.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -4766,13 +4766,17 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
47664766
case OMPC_num_threads:
47674767
case OMPC_dist_schedule:
47684768
// Do not analyse if no parent teams directive.
4769-
if (isOpenMPTeamsDirective(DSAStack->getCurrentDirective()))
4769+
if (isOpenMPTeamsDirective(Kind))
47704770
break;
47714771
continue;
47724772
case OMPC_if:
4773-
if (isOpenMPTeamsDirective(DSAStack->getCurrentDirective()) &&
4773+
if (isOpenMPTeamsDirective(Kind) &&
47744774
cast<OMPIfClause>(C)->getNameModifier() != OMPD_target)
47754775
break;
4776+
if (isOpenMPParallelDirective(Kind) &&
4777+
isOpenMPTaskLoopDirective(Kind) &&
4778+
cast<OMPIfClause>(C)->getNameModifier() != OMPD_parallel)
4779+
break;
47764780
continue;
47774781
case OMPC_schedule:
47784782
break;
@@ -4781,7 +4785,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
47814785
case OMPC_final:
47824786
case OMPC_priority:
47834787
// Do not analyze if no parent parallel directive.
4784-
if (isOpenMPParallelDirective(DSAStack->getCurrentDirective()))
4788+
if (isOpenMPParallelDirective(Kind))
47854789
break;
47864790
continue;
47874791
case OMPC_ordered:

clang/test/OpenMP/parallel_master_taskloop_loop_messages.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,19 @@ void test_loop_eh() {
733733

734734
void test_loop_firstprivate_lastprivate() {
735735
S s(4);
736+
int c;
736737
#pragma omp parallel
737738
#pragma omp parallel master taskloop lastprivate(s) firstprivate(s)
738739
for (int i = 0; i < 16; ++i)
739740
;
741+
#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}}
742+
for (int i = 0; i < 16; ++i)
743+
;
744+
#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}}
745+
for (int i = 0; i < 16; ++i)
746+
;
747+
#pragma omp parallel master taskloop if(parallel:c) default(none)
748+
for (int i = 0; i < 16; ++i)
749+
;
740750
}
741751

clang/test/OpenMP/parallel_master_taskloop_simd_loop_messages.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,19 @@ void test_loop_eh() {
728728

729729
void test_loop_firstprivate_lastprivate() {
730730
S s(4);
731+
int c;
731732
#pragma omp parallel
732733
#pragma omp parallel master taskloop simd lastprivate(s) firstprivate(s)
733734
for (int i = 0; i < 16; ++i)
734735
;
736+
#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}}
737+
for (int i = 0; i < 16; ++i)
738+
;
739+
#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}}
740+
for (int i = 0; i < 16; ++i)
741+
;
742+
#pragma omp parallel master taskloop simd if(parallel:c) default(none)
743+
for (int i = 0; i < 16; ++i)
744+
;
735745
}
736746

0 commit comments

Comments
 (0)