r319362 - [OPENMP] Allow only loop control variables in distribute simd

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 13:31:48 PST 2017


Author: abataev
Date: Wed Nov 29 13:31:48 2017
New Revision: 319362

URL: http://llvm.org/viewvc/llvm-project?rev=319362&view=rev
Log:
[OPENMP] Allow only loop control variables in distribute simd
directives.

According to the OpenMP standard, only loop control variables can be
used in linear clauses of distribute-based simd directives.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaOpenMP.cpp
    cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
    cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
    cfe/trunk/test/OpenMP/distribute_parallel_for_simd_misc_messages.c
    cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp
    cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp
    cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c
    cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_ast_print.cpp
    cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp
    cfe/trunk/test/OpenMP/target_teams_distribute_simd_ast_print.cpp
    cfe/trunk/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp
    cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp
    cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
    cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp
    cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov 29 13:31:48 2017
@@ -8957,6 +8957,8 @@ def err_omp_reduction_with_nogroup : Err
   "'reduction' clause cannot be used with 'nogroup' clause">;
 def err_omp_reduction_vla_unsupported : Error<
   "cannot generate code for reduction on %select{|array section, which requires a }0variable length array">;
+def err_omp_linear_distribute_var_non_loop_iteration : Error<
+  "only loop iteration variables are allowed in 'linear' clause in distribute directives">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Nov 29 13:31:48 2017
@@ -6808,17 +6808,6 @@ StmtResult Sema::ActOnOpenMPDistributePa
   assert((CurContext->isDependentContext() || B.builtAll()) &&
          "omp for loop exprs were not built");
 
-  if (!CurContext->isDependentContext()) {
-    // Finalize the clauses that need pre-built expressions for CodeGen.
-    for (auto C : Clauses) {
-      if (auto *LC = dyn_cast<OMPLinearClause>(C))
-        if (FinishOpenMPLinearClause(*LC, cast<DeclRefExpr>(B.IterationVarRef),
-                                     B.NumIterations, *this, CurScope,
-                                     DSAStack))
-          return StmtError();
-    }
-  }
-
   getCurFunction()->setHasBranchProtectedScope();
   return OMPDistributeParallelForDirective::Create(
       Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B,
@@ -7223,17 +7212,6 @@ StmtResult Sema::ActOnOpenMPTeamsDistrib
   assert((CurContext->isDependentContext() || B.builtAll()) &&
          "omp for loop exprs were not built");
 
-  if (!CurContext->isDependentContext()) {
-    // Finalize the clauses that need pre-built expressions for CodeGen.
-    for (auto C : Clauses) {
-      if (auto *LC = dyn_cast<OMPLinearClause>(C))
-        if (FinishOpenMPLinearClause(*LC, cast<DeclRefExpr>(B.IterationVarRef),
-                                     B.NumIterations, *this, CurScope,
-                                     DSAStack))
-          return StmtError();
-    }
-  }
-
   getCurFunction()->setHasBranchProtectedScope();
   return OMPTeamsDistributeParallelForDirective::Create(
       Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B,
@@ -7334,17 +7312,6 @@ StmtResult Sema::ActOnOpenMPTargetTeamsD
   assert((CurContext->isDependentContext() || B.builtAll()) &&
          "omp target teams distribute parallel for loop exprs were not built");
 
-  if (!CurContext->isDependentContext()) {
-    // Finalize the clauses that need pre-built expressions for CodeGen.
-    for (auto C : Clauses) {
-      if (auto *LC = dyn_cast<OMPLinearClause>(C))
-        if (FinishOpenMPLinearClause(*LC, cast<DeclRefExpr>(B.IterationVarRef),
-                                     B.NumIterations, *this, CurScope,
-                                     DSAStack))
-          return StmtError();
-    }
-  }
-
   getCurFunction()->setHasBranchProtectedScope();
   return OMPTargetTeamsDistributeParallelForDirective::Create(
       Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B,
@@ -10767,6 +10734,18 @@ static bool FinishOpenMPLinearClause(OMP
       continue;
     }
     auto &&Info = Stack->isLoopControlVariable(D);
+    // OpenMP [2.15.11, distribute simd Construct]
+    // A list item may not appear in a linear clause, unless it is the loop
+    // iteration variable.
+    if (isOpenMPDistributeDirective(Stack->getCurrentDirective()) &&
+        isOpenMPSimdDirective(Stack->getCurrentDirective()) && !Info.first) {
+      SemaRef.Diag(ELoc,
+                   diag::err_omp_linear_distribute_var_non_loop_iteration);
+      Updates.push_back(nullptr);
+      Finals.push_back(nullptr);
+      HasErrors = true;
+      continue;
+    }
     Expr *InitExpr = *CurInit;
 
     // Build privatized reference to the current linear var.

Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp Wed Nov 29 13:31:48 2017
@@ -28,17 +28,18 @@ public:
       ++this->a.a;
   }
   S7 &operator=(S7 &s) {
+    int k;
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd private(a) private(this->a)
-    for (int k = 0; k < s.a.a; ++k)
+#pragma omp distribute parallel for simd private(a) private(this->a) linear(k)
+    for (k = 0; k < s.a.a; ++k)
       ++s.a.a;
     return *this;
   }
 };
 
 // CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) private(T::a)
-// CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a)
+// CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) linear(k)
 // CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) private(this->S::a)
 
 class S8 : public S7<S> {
@@ -135,14 +136,15 @@ int main(int argc, char **argv) {
   // CHECK-NEXT: for (int j = 0; j < 10; ++j)
   // CHECK-NEXT: a++;
 
+  int i;
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd aligned(x:8) linear(h:2) safelen(8) simdlen(8)
-  for (int i = 0; i < 100; i++)
+#pragma omp distribute parallel for simd aligned(x:8) linear(i:2) safelen(8) simdlen(8)
+  for (i = 0; i < 100; i++)
     for (int j = 0; j < 200; j++)
       a += h + x[j];
-  // CHECK: #pragma omp distribute parallel for simd aligned(x: 8) linear(h: 2) safelen(8) simdlen(8)
-  // CHECK-NEXT: for (int i = 0; i < 100; i++)
+  // CHECK: #pragma omp distribute parallel for simd aligned(x: 8) linear(i: 2) safelen(8) simdlen(8)
+  // CHECK-NEXT: for (i = 0; i < 100; i++)
   // CHECK-NEXT: for (int j = 0; j < 200; j++)
   // CHECK-NEXT: a += h + x[j];
 

Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp Wed Nov 29 13:31:48 2017
@@ -18,41 +18,49 @@ void test_linear_colons()
 {
   int B = 0;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(B:bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(B:B::bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(X::x : ::z)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(B,::z, X::x)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(::z)
@@ -63,6 +71,7 @@ void test_linear_colons()
 #pragma omp distribute parallel for simd linear(B::bfoo()) // expected-error {{expected variable name}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(B::ib,B:C1+C2)
@@ -148,11 +157,13 @@ template<class I, class C> int foomain(I
 #pragma omp distribute parallel for simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -163,6 +174,7 @@ template<class I, class C> int foomain(I
 #pragma omp distribute parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear (argc : 5)
@@ -183,6 +195,7 @@ template<class I, class C> int foomain(I
 #pragma omp distribute parallel for simd linear (argv[1]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(e, g)
@@ -193,6 +206,7 @@ template<class I, class C> int foomain(I
 #pragma omp distribute parallel for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear(i)
@@ -202,28 +216,13 @@ template<class I, class C> int foomain(I
   {
     int v = 0;
     int i;
+    int k;
     #pragma omp target
     #pragma omp teams
-    #pragma omp distribute parallel for simd linear(v:i)
-    for (int k = 0; k < argc; ++k) { i = k; v += i; }
+    #pragma omp distribute parallel for simd linear(k:i)
+    for (k = 0; k < argc; ++k) { i = k; v += i; }
   }
 
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel for simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-  int v = 0;
-
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute parallel for simd linear(v:j)
-  for (int k = 0; k < argc; ++k) { ++k; v += j; }
-
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute parallel for simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
   return 0;
 }
 
@@ -262,11 +261,13 @@ int main(int argc, char **argv) {
 #pragma omp distribute parallel for simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -277,6 +278,7 @@ int main(int argc, char **argv) {
 #pragma omp distribute parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute parallel for simd linear (argc)
@@ -314,24 +316,14 @@ int main(int argc, char **argv) {
     #pragma omp target
     #pragma omp teams
     #pragma omp distribute parallel for simd linear(i)
-      for (int k = 0; k < argc; ++k) ++k;
+      for (i = 0; i < argc; ++i) ++i;
 
     #pragma omp target
     #pragma omp teams
     #pragma omp distribute parallel for simd linear(i : 4)
-      for (int k = 0; k < argc; ++k) { ++k; i += 4; }
+      for (i = 0; i < argc; ++i) { ++i; i += 4; }
   }
 
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute parallel for simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute parallel for simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
-
   foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
   return 0;
 }

Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_simd_misc_messages.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_misc_messages.c?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_misc_messages.c (original)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_misc_messages.c Wed Nov 29 13:31:48 2017
@@ -68,7 +68,7 @@ void test_non_identifiers() {
 #pragma omp target
 #pragma omp teams
 // expected-warning at +1 {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
-#pragma omp distribute parallel for simd linear(x);
+#pragma omp distribute parallel for simd firstprivate(x);
   for (i = 0; i < 16; ++i)
     ;
 
@@ -548,89 +548,6 @@ void test_linear() {
 #pragma omp distribute parallel for simd linear(x, y, z)
   for (i = 0; i < 16; ++i)
     ;
-
-  int x, y;
-#pragma omp target
-#pragma omp teams
-// expected-error at +1 {{expected expression}}
-#pragma omp distribute parallel for simd linear(x :)
-  for (i = 0; i < 16; ++i)
-    ;
-#pragma omp target
-#pragma omp teams
-// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
-#pragma omp distribute parallel for simd linear(x :, )
-  for (i = 0; i < 16; ++i)
-    ;
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute parallel for simd linear(x : 1)
-  for (i = 0; i < 16; ++i)
-    ;
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute parallel for simd linear(x : 2 * 2)
-  for (i = 0; i < 16; ++i)
-    ;
-#pragma omp target
-#pragma omp teams
-// expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
-#pragma omp distribute parallel for simd linear(x : 1, y)
-  for (i = 0; i < 16; ++i)
-    ;
-#pragma omp target
-#pragma omp teams
-// expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
-#pragma omp distribute parallel for simd linear(x : 1, y, z : 1)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-note at +2 {{defined as linear}}
-// expected-error at +1 {{linear variable cannot be linear}}
-#pragma omp distribute parallel for simd linear(x) linear(x)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-note at +2 {{defined as private}}
-// expected-error at +1 {{private variable cannot be linear}}
-#pragma omp distribute parallel for simd private(x) linear(x)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-note at +2 {{defined as linear}}
-// expected-error at +1 {{linear variable cannot be private}}
-#pragma omp distribute parallel for simd linear(x) private(x)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-warning at +1 {{zero linear step (x and other variables in clause should probably be const)}}
-#pragma omp distribute parallel for simd linear(x, y : 0)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-note at +2 {{defined as linear}}
-// expected-error at +1 {{linear variable cannot be lastprivate}}
-#pragma omp distribute parallel for simd linear(x) lastprivate(x)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-note at +2 {{defined as lastprivate}}
-// expected-error at +1 {{lastprivate variable cannot be linear}}
-#pragma omp distribute parallel for simd lastprivate(x) linear(x)
-  for (i = 0; i < 16; ++i)
-    ;
 }
 
 void test_aligned() {

Modified: cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp Wed Nov 29 13:31:48 2017
@@ -129,14 +129,15 @@ int main(int argc, char **argv) {
 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
 // CHECK-NEXT: a++;
 
+  int i;
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute simd aligned(x:8) linear(h:2) safelen(8) simdlen(8)
-  for (int i = 0; i < 100; i++)
+#pragma omp distribute simd aligned(x:8) linear(i:2) safelen(8) simdlen(8)
+  for (i = 0; i < 100; i++)
     for (int j = 0; j < 200; j++)
       a += h + x[j];
-// CHECK: #pragma omp distribute simd aligned(x: 8) linear(h: 2) safelen(8) simdlen(8)
-// CHECK-NEXT: for (int i = 0; i < 100; i++)
+// CHECK: #pragma omp distribute simd aligned(x: 8) linear(i: 2) safelen(8) simdlen(8)
+// CHECK-NEXT: for (i = 0; i < 100; i++)
 // CHECK-NEXT: for (int j = 0; j < 200; j++)
 // CHECK-NEXT: a += h + x[j];
 

Modified: cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp Wed Nov 29 13:31:48 2017
@@ -18,41 +18,49 @@ void test_linear_colons()
 {
   int B = 0;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(B:bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(B:B::bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(X::x : ::z)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(B,::z, X::x)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(::z)
@@ -63,6 +71,7 @@ void test_linear_colons()
 #pragma omp distribute simd linear(B::bfoo()) // expected-error {{expected variable name}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +3 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(B::ib,B:C1+C2)
@@ -148,11 +157,13 @@ template<class I, class C> int foomain(I
 #pragma omp distribute simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -163,6 +174,7 @@ template<class I, class C> int foomain(I
 #pragma omp distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear (argc : 5)
@@ -183,6 +195,7 @@ template<class I, class C> int foomain(I
 #pragma omp distribute simd linear (argv[1]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(e, g)
@@ -193,37 +206,12 @@ template<class I, class C> int foomain(I
 #pragma omp distribute simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear(i)
   for (int k = 0; k < argc; ++k) ++k;
 
-  #pragma omp parallel
-  {
-    int v = 0;
-    int i;
-    #pragma omp target
-    #pragma omp teams
-    #pragma omp distribute simd linear(v:i)
-    for (int k = 0; k < argc; ++k) { i = k; v += i; }
-  }
-
-#pragma omp target
-#pragma omp teams
-#pragma omp parallel for simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-  int v = 0;
-
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute simd linear(v:j)
-  for (int k = 0; k < argc; ++k) { ++k; v += j; }
-
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
   return 0;
 }
 
@@ -262,11 +250,13 @@ int main(int argc, char **argv) {
 #pragma omp distribute simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -277,6 +267,7 @@ int main(int argc, char **argv) {
 #pragma omp distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams
 #pragma omp distribute simd linear (argc)
@@ -310,28 +301,18 @@ int main(int argc, char **argv) {
 
   #pragma omp parallel
   {
-    int i;
+    int k;
     #pragma omp target
     #pragma omp teams
-    #pragma omp distribute simd linear(i)
-      for (int k = 0; k < argc; ++k) ++k;
+    #pragma omp distribute simd linear(k)
+      for (k = 0; k < argc; ++k) ++k;
 
     #pragma omp target
     #pragma omp teams
-    #pragma omp distribute simd linear(i : 4)
-      for (int k = 0; k < argc; ++k) { ++k; i += 4; }
+    #pragma omp distribute simd linear(k : 4)
+      for (k = 0; k < argc; k+=4) { }
   }
 
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
-
   foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
   return 0;
 }

Modified: cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c (original)
+++ cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c Wed Nov 29 13:31:48 2017
@@ -561,89 +561,6 @@ void test_linear() {
 #pragma omp distribute simd linear(x, y, z)
   for (i = 0; i < 16; ++i)
     ;
-
-  int x, y;
-#pragma omp target
-#pragma omp teams
-// expected-error at +1 {{expected expression}}
-#pragma omp distribute simd linear(x :)
-  for (i = 0; i < 16; ++i)
-    ;
-#pragma omp target
-#pragma omp teams
-// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
-#pragma omp distribute simd linear(x :, )
-  for (i = 0; i < 16; ++i)
-    ;
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute simd linear(x : 1)
-  for (i = 0; i < 16; ++i)
-    ;
-#pragma omp target
-#pragma omp teams
-#pragma omp distribute simd linear(x : 2 * 2)
-  for (i = 0; i < 16; ++i)
-    ;
-#pragma omp target
-#pragma omp teams
-// expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
-#pragma omp distribute simd linear(x : 1, y)
-  for (i = 0; i < 16; ++i)
-    ;
-#pragma omp target
-#pragma omp teams
-// expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
-#pragma omp distribute simd linear(x : 1, y, z : 1)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-note at +2 {{defined as linear}}
-// expected-error at +1 {{linear variable cannot be linear}}
-#pragma omp distribute simd linear(x) linear(x)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-note at +2 {{defined as private}}
-// expected-error at +1 {{private variable cannot be linear}}
-#pragma omp distribute simd private(x) linear(x)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-note at +2 {{defined as linear}}
-// expected-error at +1 {{linear variable cannot be private}}
-#pragma omp distribute simd linear(x) private(x)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-warning at +1 {{zero linear step (x and other variables in clause should probably be const)}}
-#pragma omp distribute simd linear(x, y : 0)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-note at +2 {{defined as linear}}
-// expected-error at +1 {{linear variable cannot be lastprivate}}
-#pragma omp distribute simd linear(x) lastprivate(x)
-  for (i = 0; i < 16; ++i)
-    ;
-
-#pragma omp target
-#pragma omp teams
-// expected-note at +2 {{defined as lastprivate}}
-// expected-error at +1 {{lastprivate variable cannot be linear}}
-#pragma omp distribute simd lastprivate(x) linear(x)
-  for (i = 0; i < 16; ++i)
-    ;
 }
 
 void test_aligned() {
@@ -1083,26 +1000,26 @@ void test_loop_messages() {
 }
 
 void linear_modifiers(int argc) {
-  int f;
+  int k;
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute simd linear(f)
-  for (int k = 0; k < argc; ++k) ++k;
+#pragma omp distribute simd linear(k)
+  for (k = 0; k < argc; ++k) ++k;
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute simd linear(val(f))
-  for (int k = 0; k < argc; ++k) ++k;
+#pragma omp distribute simd linear(val(k))
+  for (k = 0; k < argc; ++k) ++k;
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute simd linear(uval(f)) // expected-error {{expected 'val' modifier}}
-  for (int k = 0; k < argc; ++k) ++k;
+#pragma omp distribute simd linear(uval(k)) // expected-error {{expected 'val' modifier}}
+  for (k = 0; k < argc; ++k) ++k;
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute simd linear(ref(f)) // expected-error {{expected 'val' modifier}}
-  for (int k = 0; k < argc; ++k) ++k;
+#pragma omp distribute simd linear(ref(k)) // expected-error {{expected 'val' modifier}}
+  for (k = 0; k < argc; ++k) ++k;
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute simd linear(foo(f)) // expected-error {{expected 'val' modifier}}
-  for (int k = 0; k < argc; ++k) ++k;
+#pragma omp distribute simd linear(foo(k)) // expected-error {{expected 'val' modifier}}
+  for (k = 0; k < argc; ++k) ++k;
 }
 

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_ast_print.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_ast_print.cpp Wed Nov 29 13:31:48 2017
@@ -28,8 +28,9 @@ public:
       ++this->a.a;
   }
   S7 &operator=(S7 &s) {
-#pragma omp target teams distribute parallel for simd private(a) private(this->a)
-    for (int k = 0; k < s.a.a; ++k)
+    int k;
+#pragma omp target teams distribute parallel for simd private(a) private(this->a) linear(k)
+    for (k = 0; k < s.a.a; ++k)
       ++s.a.a;
 
     foo();
@@ -53,7 +54,7 @@ public:
   }
 };
 // CHECK: #pragma omp target teams distribute parallel for simd private(this->a) private(this->a) private(T::a)
-// CHECK: #pragma omp target teams distribute parallel for simd private(this->a) private(this->a)
+// CHECK: #pragma omp target teams distribute parallel for simd private(this->a) private(this->a) linear(k)
 // CHECK: #pragma omp target teams distribute parallel for simd default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
 // CHECK: #pragma omp target teams distribute parallel for simd simdlen(slen1) safelen(slen2) aligned(arr: alen)
 
@@ -135,10 +136,10 @@ T tmain(T argc) {
 // CHECK: #pragma omp target teams distribute parallel for simd default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
-#pragma omp target teams distribute parallel for simd simdlen(clen-1) linear(d)
+#pragma omp target teams distribute parallel for simd simdlen(clen-1)
   for (int k = 0; k < 10; ++k)
     e += d + argc;
-// CHECK: #pragma omp target teams distribute parallel for simd simdlen(clen - 1) linear(d)
+// CHECK: #pragma omp target teams distribute parallel for simd simdlen(clen - 1)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target teams distribute parallel for simd safelen(clen-1) aligned(arr:alen)
@@ -186,10 +187,10 @@ int main (int argc, char **argv) {
 // CHECK: #pragma omp target teams distribute parallel for simd default(none) private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
-#pragma omp target teams distribute parallel for simd simdlen(clen-1) linear(d)
+#pragma omp target teams distribute parallel for simd simdlen(clen-1)
   for (int k = 0; k < 10; ++k)
     e += d + argc;
-// CHECK: #pragma omp target teams distribute parallel for simd simdlen(clen - 1) linear(d)
+// CHECK: #pragma omp target teams distribute parallel for simd simdlen(clen - 1)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target teams distribute parallel for simd safelen(clen-1) aligned(arr:N+6)

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp Wed Nov 29 13:31:48 2017
@@ -18,33 +18,42 @@ void test_linear_colons()
 {
   int B = 0;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(B:bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(B:B::bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(X::x : ::z)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(B,::z, X::x)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(::z)
   for (int i = 0; i < 10; ++i) ;
 
 #pragma omp target teams distribute parallel for simd linear(B::bfoo()) // expected-error {{expected variable name}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(B::ib,B:C1+C2)
   for (int i = 0; i < 10; ++i) ;
 }
@@ -65,6 +74,7 @@ template<int L, class T, class N> T test
 
 template<int LEN> int test_warn() {
   int ind2 = 0;
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
   #pragma omp target teams distribute parallel for simd linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}}
   for (int i = 0; i < 100; i++) {
     ind2 += LEN;
@@ -118,15 +128,18 @@ template<class I, class C> int foomain(I
 #pragma omp target teams distribute parallel for simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target teams distribute parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear (argc : 5)
   for (int k = 0; k < argc; ++k) ++k;
 
@@ -139,33 +152,17 @@ template<class I, class C> int foomain(I
 #pragma omp target teams distribute parallel for simd linear (argv[1]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(e, g)
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target teams distribute parallel for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear(i)
   for (int k = 0; k < argc; ++k) ++k;
 
-  #pragma omp parallel
-  {
-    int v = 0;
-    int i;
-    #pragma omp target teams distribute parallel for simd linear(v:i)
-    for (int k = 0; k < argc; ++k) { i = k; v += i; }
-  }
-
-#pragma omp target teams distribute parallel for simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-  int v = 0;
-
-#pragma omp target teams distribute parallel for simd linear(v:j)
-  for (int k = 0; k < argc; ++k) { ++k; v += j; }
-
-#pragma omp target teams distribute parallel for simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
   return 0;
 }
 
@@ -198,15 +195,18 @@ int main(int argc, char **argv) {
 #pragma omp target teams distribute parallel for simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target teams distribute parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute parallel for simd linear (argc)
   for (int k = 0; k < argc; ++k) ++k;
 
@@ -226,22 +226,6 @@ int main(int argc, char **argv) {
 #pragma omp target teams distribute parallel for simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
   for (int k = 0; k < argc; ++k) ++k;
 
-  #pragma omp parallel
-  {
-    int i;
-    #pragma omp target teams distribute parallel for simd linear(i)
-      for (int k = 0; k < argc; ++k) ++k;
-
-    #pragma omp target teams distribute parallel for simd linear(i : 4)
-      for (int k = 0; k < argc; ++k) { ++k; i += 4; }
-  }
-
-#pragma omp target teams distribute parallel for simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-#pragma omp target teams distribute parallel for simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
-
   foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
   return 0;
 }

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_simd_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_simd_ast_print.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_teams_distribute_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_simd_ast_print.cpp Wed Nov 29 13:31:48 2017
@@ -28,8 +28,9 @@ public:
       ++this->a.a;
   }
   S7 &operator=(S7 &s) {
-#pragma omp target teams distribute simd private(a) private(this->a)
-    for (int k = 0; k < s.a.a; ++k)
+    int k;
+#pragma omp target teams distribute simd private(a) private(this->a) linear(k)
+    for (k = 0; k < s.a.a; ++k)
       ++s.a.a;
     return *this;
   }
@@ -50,7 +51,7 @@ public:
   }
 };
 // CHECK: #pragma omp target teams distribute simd private(this->a) private(this->a) private(T::a)
-// CHECK: #pragma omp target teams distribute simd private(this->a) private(this->a)
+// CHECK: #pragma omp target teams distribute simd private(this->a) private(this->a) linear(k)
 // CHECK: #pragma omp target teams distribute simd private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
 // CHECK: #pragma omp target teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr: alen)
 // CHECK: #pragma omp target teams distribute simd private(this->a) private(this->a) private(this->S::a)
@@ -129,10 +130,10 @@ T tmain(T argc) {
 // CHECK: #pragma omp target teams distribute simd private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
-#pragma omp target teams distribute simd simdlen(clen-1) linear(d)
+#pragma omp target teams distribute simd simdlen(clen-1)
   for (int k = 0; k < 10; ++k)
     e += d + argc;
-// CHECK: #pragma omp target teams distribute simd simdlen(clen - 1) linear(d)
+// CHECK: #pragma omp target teams distribute simd simdlen(clen - 1)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target teams distribute simd safelen(clen-1) aligned(arr:alen)
@@ -180,10 +181,10 @@ int main (int argc, char **argv) {
 // CHECK: #pragma omp target teams distribute simd private(b) firstprivate(argc) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
-#pragma omp target teams distribute simd simdlen(clen-1) linear(d)
+#pragma omp target teams distribute simd simdlen(clen-1)
   for (int k = 0; k < 10; ++k)
     e += d + argc;
-// CHECK: #pragma omp target teams distribute simd simdlen(clen - 1) linear(d)
+// CHECK: #pragma omp target teams distribute simd simdlen(clen - 1)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target teams distribute simd safelen(clen-1) aligned(arr:N+6)

Modified: cfe/trunk/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp Wed Nov 29 13:31:48 2017
@@ -18,33 +18,42 @@ void test_linear_colons()
 {
   int B = 0;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(B:bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(B:B::bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(X::x : ::z)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(B,::z, X::x)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(::z)
   for (int i = 0; i < 10; ++i) ;
 
 #pragma omp target teams distribute simd linear(B::bfoo()) // expected-error {{expected variable name}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +1 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(B::ib,B:C1+C2)
   for (int i = 0; i < 10; ++i) ;
 }
@@ -65,6 +74,7 @@ template<int L, class T, class N> T test
 
 template<int LEN> int test_warn() {
   int ind2 = 0;
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
   #pragma omp target teams distribute simd linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}}
   for (int i = 0; i < 100; i++) {
     ind2 += LEN;
@@ -118,15 +128,18 @@ template<class I, class C> int foomain(I
 #pragma omp target teams distribute simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target teams distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear (argc : 5)
   for (int k = 0; k < argc; ++k) ++k;
 
@@ -139,33 +152,17 @@ template<class I, class C> int foomain(I
 #pragma omp target teams distribute simd linear (argv[1]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(e, g)
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target teams distribute simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear(i)
   for (int k = 0; k < argc; ++k) ++k;
 
-  #pragma omp parallel
-  {
-    int v = 0;
-    int i;
-    #pragma omp target teams distribute simd linear(v:i)
-    for (int k = 0; k < argc; ++k) { i = k; v += i; }
-  }
-
-#pragma omp target teams distribute simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-  int v = 0;
-
-#pragma omp target teams distribute simd linear(v:j)
-  for (int k = 0; k < argc; ++k) { ++k; v += j; }
-
-#pragma omp target teams distribute simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
   return 0;
 }
 
@@ -198,15 +195,18 @@ int main(int argc, char **argv) {
 #pragma omp target teams distribute simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
 #pragma omp target teams distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target teams distribute simd linear (argc)
   for (int k = 0; k < argc; ++k) ++k;
 
@@ -226,22 +226,6 @@ int main(int argc, char **argv) {
 #pragma omp target teams distribute simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
   for (int k = 0; k < argc; ++k) ++k;
 
-  #pragma omp parallel
-  {
-    int i;
-    #pragma omp target teams distribute simd linear(i)
-      for (int k = 0; k < argc; ++k) ++k;
-
-    #pragma omp target teams distribute simd linear(i : 4)
-      for (int k = 0; k < argc; ++k) { ++k; i += 4; }
-  }
-
-#pragma omp target teams distribute simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-#pragma omp target teams distribute simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
-
   foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
   return 0;
 }

Modified: cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp Wed Nov 29 13:31:48 2017
@@ -29,9 +29,10 @@ public:
       ++this->a.a;
   }
   S7 &operator=(S7 &s) {
+    int k;
 #pragma omp target
-#pragma omp teams distribute parallel for simd private(a) private(this->a)
-    for (int k = 0; k < s.a.a; ++k)
+#pragma omp teams distribute parallel for simd private(a) private(this->a) linear(k)
+    for (k = 0; k < s.a.a; ++k)
       ++s.a.a;
 
     foo();
@@ -59,7 +60,7 @@ public:
 // CHECK: #pragma omp target
 // CHECK-NEXT: #pragma omp teams distribute parallel for simd private(this->a) private(this->a) private(T::a)
 // CHECK: #pragma omp target
-// CHECK-NEXT: #pragma omp teams distribute parallel for simd private(this->a) private(this->a)
+// CHECK-NEXT: #pragma omp teams distribute parallel for simd private(this->a) private(this->a) linear(k)
 // CHECK: #pragma omp target
 // CHECK-NEXT: #pragma omp teams distribute parallel for simd default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
 // CHECK: #pragma omp target
@@ -161,11 +162,11 @@ T tmain(T argc) {
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target
-#pragma omp teams distribute parallel for simd simdlen(clen-1) linear(d)
+#pragma omp teams distribute parallel for simd simdlen(clen-1)
   for (int k = 0; k < 10; ++k)
     e += d + argc;
 // CHECK: #pragma omp target
-// CHECK-NEXT: #pragma omp teams distribute parallel for simd simdlen(clen - 1) linear(d)
+// CHECK-NEXT: #pragma omp teams distribute parallel for simd simdlen(clen - 1)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target
@@ -224,11 +225,11 @@ int main (int argc, char **argv) {
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target
-#pragma omp teams distribute parallel for simd simdlen(clen-1) linear(d)
+#pragma omp teams distribute parallel for simd simdlen(clen-1)
   for (int k = 0; k < 10; ++k)
     e += d + argc;
 // CHECK: #pragma omp target
-// CHECK-NEXT: #pragma omp teams distribute parallel for simd simdlen(clen - 1) linear(d)
+// CHECK-NEXT: #pragma omp teams distribute parallel for simd simdlen(clen - 1)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target

Modified: cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp Wed Nov 29 13:31:48 2017
@@ -18,34 +18,42 @@ void test_linear_colons()
 {
   int B = 0;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(B:bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(B:B::bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(X::x : ::z)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(B,::z, X::x)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(::z)
   for (int i = 0; i < 10; ++i) ;
@@ -54,6 +62,7 @@ void test_linear_colons()
 #pragma omp teams distribute parallel for simd linear(B::bfoo()) // expected-error {{expected variable name}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(B::ib,B:C1+C2)
   for (int i = 0; i < 10; ++i) ;
@@ -76,6 +85,7 @@ template<int L, class T, class N> T test
 
 template<int LEN> int test_warn() {
   int ind2 = 0;
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
   #pragma omp target
   #pragma omp teams distribute parallel for simd linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}}
   for (int i = 0; i < 100; i++) {
@@ -133,10 +143,12 @@ template<class I, class C> int foomain(I
 #pragma omp teams distribute parallel for simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
@@ -145,6 +157,7 @@ template<class I, class C> int foomain(I
 #pragma omp teams distribute parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear (argc : 5)
   for (int k = 0; k < argc; ++k) ++k;
@@ -161,6 +174,7 @@ template<class I, class C> int foomain(I
 #pragma omp teams distribute parallel for simd linear (argv[1]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(e, g)
   for (int k = 0; k < argc; ++k) ++k;
@@ -169,32 +183,11 @@ template<class I, class C> int foomain(I
 #pragma omp teams distribute parallel for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear(i)
   for (int k = 0; k < argc; ++k) ++k;
 
-  #pragma omp parallel
-  {
-    int v = 0;
-    int i;
-    #pragma omp target
-    #pragma omp teams distribute parallel for simd linear(v:i)
-    for (int k = 0; k < argc; ++k) { i = k; v += i; }
-  }
-
-#pragma omp target
-#pragma omp teams distribute parallel for simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-  int v = 0;
-
-#pragma omp target
-#pragma omp teams distribute parallel for simd linear(v:j)
-  for (int k = 0; k < argc; ++k) { ++k; v += j; }
-
-#pragma omp target
-#pragma omp teams distribute parallel for simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
   return 0;
 }
 
@@ -230,10 +223,12 @@ int main(int argc, char **argv) {
 #pragma omp teams distribute parallel for simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
@@ -242,6 +237,7 @@ int main(int argc, char **argv) {
 #pragma omp teams distribute parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute parallel for simd linear (argc)
   for (int k = 0; k < argc; ++k) ++k;
@@ -267,26 +263,6 @@ int main(int argc, char **argv) {
 #pragma omp teams distribute parallel for simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
   for (int k = 0; k < argc; ++k) ++k;
 
-  #pragma omp parallel
-  {
-    int i;
-    #pragma omp target
-    #pragma omp teams distribute parallel for simd linear(i)
-      for (int k = 0; k < argc; ++k) ++k;
-
-    #pragma omp target
-    #pragma omp teams distribute parallel for simd linear(i : 4)
-      for (int k = 0; k < argc; ++k) { ++k; i += 4; }
-  }
-
-#pragma omp target
-#pragma omp teams distribute parallel for simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-#pragma omp target
-#pragma omp teams distribute parallel for simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
-
   foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
   return 0;
 }

Modified: cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp Wed Nov 29 13:31:48 2017
@@ -29,9 +29,10 @@ public:
       ++this->a.a;
   }
   S7 &operator=(S7 &s) {
+    int k;
 #pragma omp target
-#pragma omp teams distribute simd private(a) private(this->a)
-    for (int k = 0; k < s.a.a; ++k)
+#pragma omp teams distribute simd private(a) private(this->a) linear(k)
+    for (k = 0; k < s.a.a; ++k)
       ++s.a.a;
     return *this;
   }
@@ -56,7 +57,7 @@ public:
 // CHECK: #pragma omp target
 // CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a) private(T::a)
 // CHECK: #pragma omp target
-// CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a)
+// CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a) linear(k)
 // CHECK: #pragma omp target
 // CHECK-NEXT: #pragma omp teams distribute simd default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d)
 // CHECK: #pragma omp target
@@ -155,11 +156,11 @@ T tmain(T argc) {
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target
-#pragma omp teams distribute simd simdlen(clen-1) linear(d)
+#pragma omp teams distribute simd simdlen(clen-1)
   for (int k = 0; k < 10; ++k)
     e += d + argc;
 // CHECK: #pragma omp target
-// CHECK-NEXT: #pragma omp teams distribute simd simdlen(clen - 1) linear(d)
+// CHECK-NEXT: #pragma omp teams distribute simd simdlen(clen - 1)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target
@@ -218,11 +219,11 @@ int main (int argc, char **argv) {
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target
-#pragma omp teams distribute simd simdlen(clen-1) linear(d)
+#pragma omp teams distribute simd simdlen(clen-1)
   for (int k = 0; k < 10; ++k)
     e += d + argc;
 // CHECK: #pragma omp target
-// CHECK-NEXT: #pragma omp teams distribute simd simdlen(clen - 1) linear(d)
+// CHECK-NEXT: #pragma omp teams distribute simd simdlen(clen - 1)
 // CHECK-NEXT: for (int k = 0; k < 10; ++k)
 // CHECK-NEXT: e += d + argc;
 #pragma omp target

Modified: cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp?rev=319362&r1=319361&r2=319362&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp Wed Nov 29 13:31:48 2017
@@ -18,34 +18,42 @@ void test_linear_colons()
 {
   int B = 0;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(B:bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(B:B::bfoo())
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(X::x : ::z)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(B,::z, X::x)
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(::z)
   for (int i = 0; i < 10; ++i) ;
@@ -54,6 +62,7 @@ void test_linear_colons()
 #pragma omp teams distribute simd linear(B::bfoo()) // expected-error {{expected variable name}}
   for (int i = 0; i < 10; ++i) ;
 
+// expected-error at +2 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(B::ib,B:C1+C2)
   for (int i = 0; i < 10; ++i) ;
@@ -76,6 +85,7 @@ template<int L, class T, class N> T test
 
 template<int LEN> int test_warn() {
   int ind2 = 0;
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
   #pragma omp target
   #pragma omp teams distribute simd linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}}
   for (int i = 0; i < 100; i++) {
@@ -133,10 +143,12 @@ template<class I, class C> int foomain(I
 #pragma omp teams distribute simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
@@ -145,6 +157,7 @@ template<class I, class C> int foomain(I
 #pragma omp teams distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear (argc : 5)
   for (int k = 0; k < argc; ++k) ++k;
@@ -161,6 +174,7 @@ template<class I, class C> int foomain(I
 #pragma omp teams distribute simd linear (argv[1]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(e, g)
   for (int k = 0; k < argc; ++k) ++k;
@@ -169,32 +183,11 @@ template<class I, class C> int foomain(I
 #pragma omp teams distribute simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear(i)
   for (int k = 0; k < argc; ++k) ++k;
 
-  #pragma omp parallel
-  {
-    int v = 0;
-    int i;
-    #pragma omp target
-    #pragma omp teams distribute simd linear(v:i)
-    for (int k = 0; k < argc; ++k) { i = k; v += i; }
-  }
-
-#pragma omp target
-#pragma omp teams distribute simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-  int v = 0;
-
-#pragma omp target
-#pragma omp teams distribute simd linear(v:j)
-  for (int k = 0; k < argc; ++k) { ++k; v += j; }
-
-#pragma omp target
-#pragma omp teams distribute simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
   return 0;
 }
 
@@ -230,10 +223,12 @@ int main(int argc, char **argv) {
 #pragma omp teams distribute simd linear () // expected-error {{expected expression}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int k = 0; k < argc; ++k) ++k;
@@ -242,6 +237,7 @@ int main(int argc, char **argv) {
 #pragma omp teams distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
 
+// expected-error at +2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
 #pragma omp target
 #pragma omp teams distribute simd linear (argc)
   for (int k = 0; k < argc; ++k) ++k;
@@ -267,26 +263,6 @@ int main(int argc, char **argv) {
 #pragma omp teams distribute simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
   for (int k = 0; k < argc; ++k) ++k;
 
-  #pragma omp parallel
-  {
-    int i;
-    #pragma omp target
-    #pragma omp teams distribute simd linear(i)
-      for (int k = 0; k < argc; ++k) ++k;
-
-    #pragma omp target
-    #pragma omp teams distribute simd linear(i : 4)
-      for (int k = 0; k < argc; ++k) { ++k; i += 4; }
-  }
-
-#pragma omp target
-#pragma omp teams distribute simd linear(j)
-  for (int k = 0; k < argc; ++k) ++k;
-
-#pragma omp target
-#pragma omp teams distribute simd linear(i)
-  for (int k = 0; k < argc; ++k) ++k;
-
   foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
   return 0;
 }




More information about the cfe-commits mailing list