[clang] 77d049d - [OPENMP]Fix datasharing checks for if clause in parallel taskloop

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 21 08:24:28 PST 2019


Author: Alexey Bataev
Date: 2019-11-21T11:20:38-05:00
New Revision: 77d049d0c653798698fa24556115874828aae87b

URL: https://github.com/llvm/llvm-project/commit/77d049d0c653798698fa24556115874828aae87b
DIFF: https://github.com/llvm/llvm-project/commit/77d049d0c653798698fa24556115874828aae87b.diff

LOG: [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.

Added: 
    

Modified: 
    clang/lib/Sema/SemaOpenMP.cpp
    clang/test/OpenMP/parallel_master_taskloop_loop_messages.cpp
    clang/test/OpenMP/parallel_master_taskloop_simd_loop_messages.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1ff25e7eb47f..d603d2139a0c 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -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:

diff  --git a/clang/test/OpenMP/parallel_master_taskloop_loop_messages.cpp b/clang/test/OpenMP/parallel_master_taskloop_loop_messages.cpp
index a212a83ee662..76411969924b 100644
--- a/clang/test/OpenMP/parallel_master_taskloop_loop_messages.cpp
+++ b/clang/test/OpenMP/parallel_master_taskloop_loop_messages.cpp
@@ -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)
+    ;
 }
 

diff  --git a/clang/test/OpenMP/parallel_master_taskloop_simd_loop_messages.cpp b/clang/test/OpenMP/parallel_master_taskloop_simd_loop_messages.cpp
index 71b458dc2329..9f6c55e1c4c5 100644
--- a/clang/test/OpenMP/parallel_master_taskloop_simd_loop_messages.cpp
+++ b/clang/test/OpenMP/parallel_master_taskloop_simd_loop_messages.cpp
@@ -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)
+    ;
 }
 


        


More information about the cfe-commits mailing list