Author: abataev
Date: Mon May 15 11:26:15 2017
New Revision: 303077

URL: http://llvm.org/viewvc/llvm-project?rev=303077&view=rev
Log:
[OPENMP] Check DSA for variables captured by value.

Currently clang checks for default data sharing attributes only for
variables captured in OpenMP regions by reference. Patch adds checks for
variables captured by value.

Added:
    cfe/trunk/test/OpenMP/report_default_DSA.cpp
Modified:
    cfe/trunk/lib/AST/Stmt.cpp

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=303077&r1=303076&r2=303077&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Mon May 15 11:26:15 2017
@@ -1112,7 +1112,7 @@ void CapturedStmt::setCapturedRegionKind
 
 bool CapturedStmt::capturesVariable(const VarDecl *Var) const {
   for (const auto &I : captures()) {
-    if (!I.capturesVariable())
+    if (!I.capturesVariable() && !I.capturesVariableByCopy())
       continue;
 
     // This does not handle variable redeclarations. This should be

Added: cfe/trunk/test/OpenMP/report_default_DSA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/report_default_DSA.cpp?rev=303077&view=auto
==============================================================================
--- cfe/trunk/test/OpenMP/report_default_DSA.cpp (added)
+++ cfe/trunk/test/OpenMP/report_default_DSA.cpp Mon May 15 11:26:15 2017
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 %s
+
+void foo(int x, int n) {
+  double vec[n];
+  for (int iter = 0; iter < x; iter++) {
+#pragma omp target teams distribute parallel for map( \
+    from                                              \
+    : vec [0:n]) default(none)
+    // expected-error@+1 {{variable 'n' must have explicitly specified data 
sharing attributes}}
+    for (int ii = 0; ii < n; ii++) {
+      // expected-error@+3 {{variable 'iter' must have explicitly specified 
data sharing attributes}}
+      // expected-error@+2 {{variable 'vec' must have explicitly specified 
data sharing attributes}}
+      // expected-error@+1 {{variable 'x' must have explicitly specified data 
sharing attributes}}
+      vec[ii] = iter + ii + x;
+    }
+  }
+}
+


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to