[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.
This commit is contained in:
Alexey Bataev 2019-11-21 11:03:26 -05:00
parent 4ae0a13256
commit 77d049d0c6
3 changed files with 27 additions and 3 deletions

View File

@ -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;
@ -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:

View File

@ -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)
;
}

View File

@ -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)
;
}