r349635 - [OpenMP] Fix data sharing analysis in nested clause

Joel E. Denny via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 19 07:59:48 PST 2018


Author: jdenny
Date: Wed Dec 19 07:59:47 2018
New Revision: 349635

URL: http://llvm.org/viewvc/llvm-project?rev=349635&view=rev
Log:
[OpenMP] Fix data sharing analysis in nested clause

Without this patch, clang doesn't complain that X needs explicit data
sharing attributes in the following:

```
 #pragma omp target teams default(none)
 {
   #pragma omp parallel num_threads(X)
     ;
 }
```

However, clang does produce that complaint after the braces are
removed.  With this patch, clang complains in both cases.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D55861

Modified:
    cfe/trunk/lib/Sema/SemaOpenMP.cpp
    cfe/trunk/test/OpenMP/target_teams_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=349635&r1=349634&r2=349635&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Dec 19 07:59:47 2018
@@ -2390,13 +2390,9 @@ public:
   void VisitStmt(Stmt *S) {
     for (Stmt *C : S->children()) {
       if (C) {
-        if (auto *OED = dyn_cast<OMPExecutableDirective>(C)) {
-          // Check implicitly captured variables in the task-based directives to
-          // check if they must be firstprivatized.
-          VisitSubCaptures(OED);
-        } else {
-          Visit(C);
-        }
+        // Check implicitly captured variables in the task-based directives to
+        // check if they must be firstprivatized.
+        Visit(C);
       }
     }
   }

Modified: cfe/trunk/test/OpenMP/target_teams_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_messages.cpp?rev=349635&r1=349634&r2=349635&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_teams_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_teams_messages.cpp Wed Dec 19 07:59:47 2018
@@ -50,6 +50,16 @@ int main(int argc, char **argv) {
 #pragma omp target teams default(none)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#pragma omp target teams default(none)
+#pragma omp parallel num_threads(argc) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+  ;
+
+#pragma omp target teams default(none)
+  {
+#pragma omp parallel num_threads(argc) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+    ;
+  }
+
   goto L2; // expected-error {{use of undeclared label 'L2'}}
 #pragma omp target teams
   L2:




More information about the cfe-commits mailing list