]> granicus.if.org Git - clang/commitdiff
[OpenMP] Fix data sharing analysis in nested clause
authorJoel E. Denny <jdenny.ornl@gmail.com>
Wed, 19 Dec 2018 15:59:47 +0000 (15:59 +0000)
committerJoel E. Denny <jdenny.ornl@gmail.com>
Wed, 19 Dec 2018 15:59:47 +0000 (15:59 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349635 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOpenMP.cpp
test/OpenMP/target_teams_messages.cpp

index 38a329a1fdf1f382f2489962569786a92acb24a3..c207ba9bd324d8ea0856af7b2cf657629d951040 100644 (file)
@@ -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);
       }
     }
   }
index 3a367bfc7e4edd95794e9f732a8674b4bfa5d045..bc068f87b619084968cd4f343c7bee386cb569dc 100644 (file)
@@ -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: