summaryrefslogtreecommitdiffstats
path: root/clang/test/OpenMP
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-10-09 04:18:56 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-10-09 04:18:56 +0000
commit13314bf5269a41a583c0019fe74bb1cdb86e7d44 (patch)
treebad6efc4d1819c103d94705825d41d878e5430ae /clang/test/OpenMP
parent7be03d09cd2e2bc76c86bb0730770796629fb76c (diff)
downloadbcm5719-llvm-13314bf5269a41a583c0019fe74bb1cdb86e7d44.tar.gz
bcm5719-llvm-13314bf5269a41a583c0019fe74bb1cdb86e7d44.zip
[OPENMP] 'omp teams' directive basic support.
Includes parsing and semantic analysis for 'omp teams' directive support from OpenMP 4.0. Adds additional analysis to 'omp target' directive with 'omp teams' directive. llvm-svn: 219385
Diffstat (limited to 'clang/test/OpenMP')
-rw-r--r--clang/test/OpenMP/nesting_of_regions.cpp413
-rw-r--r--clang/test/OpenMP/teams_ast_print.cpp112
-rw-r--r--clang/test/OpenMP/teams_default_messages.cpp34
-rw-r--r--clang/test/OpenMP/teams_firstprivate_messages.cpp124
-rw-r--r--clang/test/OpenMP/teams_messages.cpp82
-rw-r--r--clang/test/OpenMP/teams_private_messages.cpp119
-rw-r--r--clang/test/OpenMP/teams_reduction_messages.cpp307
-rw-r--r--clang/test/OpenMP/teams_shared_messages.cpp125
8 files changed, 1316 insertions, 0 deletions
diff --git a/clang/test/OpenMP/nesting_of_regions.cpp b/clang/test/OpenMP/nesting_of_regions.cpp
index 0bc61f6e0d1..a948ca3e3bc 100644
--- a/clang/test/OpenMP/nesting_of_regions.cpp
+++ b/clang/test/OpenMP/nesting_of_regions.cpp
@@ -95,6 +95,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp parallel
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// SIMD DIRECTIVE
#pragma omp simd
@@ -217,6 +222,11 @@ void foo() {
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
+#pragma omp simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ ++a;
+ }
// FOR DIRECTIVE
#pragma omp for
@@ -362,6 +372,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// FOR SIMD DIRECTIVE
#pragma omp for simd
@@ -484,6 +499,11 @@ void foo() {
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
+#pragma omp for simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ ++a;
+ }
// SECTIONS DIRECTIVE
#pragma omp sections
@@ -636,6 +656,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp sections
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
@@ -823,6 +848,12 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp sections
+ {
+#pragma omp section
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// SINGLE DIRECTIVE
#pragma omp single
@@ -958,6 +989,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp single
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// MASTER DIRECTIVE
#pragma omp master
@@ -1093,6 +1129,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp master
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// CRITICAL DIRECTIVE
#pragma omp critical
@@ -1242,6 +1283,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp critical
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
@@ -1392,6 +1438,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp parallel for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// PARALLEL FOR SIMD DIRECTIVE
#pragma omp parallel for simd
@@ -1542,6 +1593,11 @@ void foo() {
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
+#pragma omp parallel for simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ ++a;
+ }
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
@@ -1683,6 +1739,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp parallel sections
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// TASK DIRECTIVE
#pragma omp task
@@ -1770,6 +1831,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp task
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// ORDERED DIRECTIVE
#pragma omp ordered
@@ -1905,6 +1971,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp ordered
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// ATOMIC DIRECTIVE
#pragma omp atomic
@@ -2047,6 +2118,12 @@ void foo() {
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
++a;
}
+#pragma omp atomic
+ // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+ {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ ++a;
+ }
// TARGET DIRECTIVE
#pragma omp target
@@ -2141,6 +2218,137 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp target
+ {
+#pragma omp teams
+ ++a;
+ }
+#pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}}
+ {
+ ++a; // expected-note {{statement outside teams construct here}}
+#pragma omp teams // expected-note {{nested teams construct here}}
+ ++a;
+ }
+
+// TEAMS DIRECTIVE
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel
+ bar();
+#pragma omp target
+#pragma omp teams
+#pragma omp for // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp simd' directive into a parallel region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams region}}
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+#pragma omp single // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+ bar();
+
+#pragma omp target
+#pragma omp teams
+#pragma omp master // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp master' directive into a parallel region?}}
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+#pragma omp critical // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp critical' directive into a parallel region?}}
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for simd
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel sections
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+#pragma omp task // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp task' directive into a parallel region?}}
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp taskyield // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskyield' directive into a parallel region?}}
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp barrier' directive into a parallel region?}}
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp taskwait // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskwait' directive into a parallel region?}}
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp flush // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp flush' directive into a parallel region?}}
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp atomic // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp atomic' directive into a parallel region?}}
+ ++a;
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp target // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target' directive into a parallel region?}}
+ ++a;
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
}
void foo() {
@@ -2235,6 +2443,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp parallel
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// SIMD DIRECTIVE
#pragma omp simd
@@ -2350,6 +2563,11 @@ void foo() {
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
+#pragma omp simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ ++a;
+ }
// FOR DIRECTIVE
#pragma omp for
@@ -2485,6 +2703,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// FOR SIMD DIRECTIVE
#pragma omp for simd
@@ -2600,6 +2823,11 @@ void foo() {
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
+#pragma omp for simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ ++a;
+ }
// SECTIONS DIRECTIVE
#pragma omp sections
@@ -2727,6 +2955,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp sections
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
@@ -2918,6 +3151,14 @@ void foo() {
++a;
}
}
+#pragma omp sections
+ {
+#pragma omp section
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
+ }
// SINGLE DIRECTIVE
#pragma omp single
@@ -3043,6 +3284,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp single
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// MASTER DIRECTIVE
#pragma omp master
@@ -3178,6 +3424,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp master
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// CRITICAL DIRECTIVE
#pragma omp critical
@@ -3332,6 +3583,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp critical
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
@@ -3482,6 +3738,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp parallel for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// PARALLEL FOR SIMD DIRECTIVE
#pragma omp parallel for simd
@@ -3632,6 +3893,11 @@ void foo() {
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
+#pragma omp parallel for simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ ++a;
+ }
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
@@ -3769,6 +4035,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp parallel sections
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// TASK DIRECTIVE
#pragma omp task
@@ -3855,6 +4126,11 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp task
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
// ATOMIC DIRECTIVE
#pragma omp atomic
@@ -3997,6 +4273,12 @@ void foo() {
#pragma omp target // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
++a;
}
+#pragma omp atomic
+ // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+ {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ ++a;
+ }
// TARGET DIRECTIVE
#pragma omp target
@@ -4091,6 +4373,137 @@ void foo() {
#pragma omp target
++a;
}
+#pragma omp target
+ {
+#pragma omp teams
+ ++a;
+ }
+#pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}}
+ {
+ ++a; // expected-note {{statement outside teams construct here}}
+#pragma omp teams // expected-note {{nested teams construct here}}
+ ++a;
+ }
+
+// TEAMS DIRECTIVE
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel
+ bar();
+#pragma omp target
+#pragma omp teams
+#pragma omp for // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp simd' directive into a parallel region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams region}}
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+#pragma omp single // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+ bar();
+
+#pragma omp target
+#pragma omp teams
+#pragma omp master // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp master' directive into a parallel region?}}
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+#pragma omp critical // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp critical' directive into a parallel region?}}
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for simd
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel sections
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+#pragma omp task // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp task' directive into a parallel region?}}
+ {
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp taskyield // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskyield' directive into a parallel region?}}
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp barrier' directive into a parallel region?}}
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp taskwait // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskwait' directive into a parallel region?}}
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp flush // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp flush' directive into a parallel region?}}
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+ bar();
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp atomic // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp atomic' directive into a parallel region?}}
+ ++a;
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp target // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target' directive into a parallel region?}}
+ ++a;
+ }
+#pragma omp target
+#pragma omp teams
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
return foo<int>();
}
diff --git a/clang/test/OpenMP/teams_ast_print.cpp b/clang/test/OpenMP/teams_ast_print.cpp
new file mode 100644
index 00000000000..394ec73a841
--- /dev/null
+++ b/clang/test/OpenMP/teams_ast_print.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+template <class T>
+struct S {
+ operator T() {return T();}
+ static T TS;
+ #pragma omp threadprivate(TS)
+};
+
+// CHECK: template <class T = int> struct S {
+// CHECK: static int TS;
+// CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
+// CHECK-NEXT: }
+// CHECK: template <class T = long> struct S {
+// CHECK: static long TS;
+// CHECK-NEXT: #pragma omp threadprivate(S<long>::TS)
+// CHECK-NEXT: }
+// CHECK: template <class T> struct S {
+// CHECK: static T TS;
+// CHECK-NEXT: #pragma omp threadprivate(S::TS)
+// CHECK: };
+
+template <typename T, int C>
+T tmain(T argc, T *argv) {
+ T b = argc, c, d, e, f, g;
+ static T a;
+ S<T> s;
+#pragma omp target
+#pragma omp teams
+ a=2;
+#pragma omp target
+#pragma omp teams default(none), private(argc,b) firstprivate(argv) shared (d) reduction(+:c) reduction(max:e)
+ foo();
+#pragma omp target
+#pragma omp teams reduction(^:e, f) reduction(&& : g)
+ foo();
+ return 0;
+}
+
+// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) {
+// CHECK-NEXT: int b = argc, c, d, e, f, g;
+// CHECK-NEXT: static int a;
+// CHECK-NEXT: S<int> s;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
+// CHECK-NEXT: foo()
+// CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) {
+// CHECK-NEXT: long b = argc, c, d, e, f, g;
+// CHECK-NEXT: static long a;
+// CHECK-NEXT: S<long> s;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
+// CHECK-NEXT: foo()
+// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
+// CHECK-NEXT: T b = argc, c, d, e, f, g;
+// CHECK-NEXT: static T a;
+// CHECK-NEXT: S<T> s;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
+// CHECK-NEXT: foo()
+
+enum Enum { };
+
+int main (int argc, char **argv) {
+ long x;
+ int b = argc, c, d, e, f, g;
+ static int a;
+ #pragma omp threadprivate(a)
+ Enum ee;
+// CHECK: Enum ee;
+#pragma omp target
+#pragma omp teams
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams
+ a=2;
+// CHECK-NEXT: a = 2;
+#pragma omp target
+#pragma omp teams default(none), private(argc,b) firstprivate(argv) reduction(| : c, d) reduction(* : e)
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) reduction(|: c,d) reduction(*: e)
+ foo();
+// CHECK-NEXT: foo();
+ return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
+}
+
+#endif
diff --git a/clang/test/OpenMP/teams_default_messages.cpp b/clang/test/OpenMP/teams_default_messages.cpp
new file mode 100644
index 00000000000..4f5a267150f
--- /dev/null
+++ b/clang/test/OpenMP/teams_default_messages.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -o - %s
+
+void foo();
+
+int main(int argc, char **argv) {
+ #pragma omp target
+ #pragma omp teams default // expected-error {{expected '(' after 'default'}}
+ foo();
+ #pragma omp target
+ #pragma omp teams default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target
+ #pragma omp teams default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+ foo();
+ #pragma omp target
+ #pragma omp teams default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target
+ #pragma omp teams default (shared), default(shared) // expected-error {{directive '#pragma omp teams' cannot contain more than one 'default' clause}}
+ foo();
+ #pragma omp target
+ #pragma omp teams default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+ foo();
+
+ #pragma omp target
+ #pragma omp teams default(none)
+ ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+ #pragma omp target
+ #pragma omp teams default(none)
+ #pragma omp parallel default(shared)
+ ++argc;
+ return 0;
+}
diff --git a/clang/test/OpenMP/teams_firstprivate_messages.cpp b/clang/test/OpenMP/teams_firstprivate_messages.cpp
new file mode 100644
index 00000000000..3d4a21999ee
--- /dev/null
+++ b/clang/test/OpenMP/teams_firstprivate_messages.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+ return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+ mutable int a;
+
+public:
+ S2() : a(0) {}
+ S2(const S2 &s2) : a(s2.a) {}
+ static float S2s;
+ static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+ int a;
+
+public:
+ S3() : a(0) {}
+ S3(const S3 &s3) : a(s3.a) {}
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+ int a;
+ S4();
+ S4(const S4 &s4); // expected-note {{implicitly declared private here}}
+public:
+ S4(int v) : a(v) {}
+};
+class S5 {
+ int a;
+ S5() : a(0) {}
+ S5(const S5 &s5) : a(s5.a) {} // expected-note {{implicitly declared private here}}
+public:
+ S5(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
+
+int main(int argc, char **argv) {
+ const int d = 5;
+ const int da[5] = {0};
+ S4 e(4);
+ S5 g(5);
+ int i;
+ int &j = i; // expected-note {{'j' defined here}}
+#pragma omp target
+#pragma omp teams firstprivate // expected-error {{expected '(' after 'firstprivate'}}
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate() // expected-error {{expected expression}}
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(argc)
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(argv[1]) // expected-error {{expected variable name}}
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(ba)
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(ca)
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(da)
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(S2::S2s)
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(S2::S2sc)
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
+ foo();
+#pragma omp target
+#pragma omp teams private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
+ foo();
+#pragma omp target
+#pragma omp teams shared(i)
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(i)
+ foo();
+#pragma omp target
+#pragma omp teams firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
+ foo();
+
+ return 0;
+}
diff --git a/clang/test/OpenMP/teams_messages.cpp b/clang/test/OpenMP/teams_messages.cpp
new file mode 100644
index 00000000000..56ed548a037
--- /dev/null
+++ b/clang/test/OpenMP/teams_messages.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -std=c++11 -o - %s
+
+void foo() {
+}
+
+#pragma omp teams // expected-error {{unexpected OpenMP directive '#pragma omp teams'}}
+
+int main(int argc, char **argv) {
+ #pragma omp target
+ #pragma omp teams { // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+ foo();
+ #pragma omp target
+ #pragma omp teams ( // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+ foo();
+ #pragma omp target
+ #pragma omp teams [ // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+ foo();
+ #pragma omp target
+ #pragma omp teams ] // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+ foo();
+ #pragma omp target
+ #pragma omp teams ) // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+ foo();
+ #pragma omp target
+ #pragma omp teams } // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+ foo();
+ #pragma omp target
+ #pragma omp teams
+ foo();
+ // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams' are ignored}}
+ #pragma omp target
+ #pragma omp teams unknown()
+ foo();
+ L1:
+ foo();
+ #pragma omp target
+ #pragma omp teams
+ ;
+ #pragma omp target
+ #pragma omp teams
+ {
+ goto L1; // expected-error {{use of undeclared label 'L1'}}
+ argc++;
+ }
+
+ for (int i = 0; i < 10; ++i) {
+ switch(argc) {
+ case (0):
+ #pragma omp target
+ #pragma omp teams
+ {
+ foo();
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ }
+ default:
+ break;
+ }
+ }
+ #pragma omp target
+ #pragma omp teams default(none)
+ ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+ goto L2; // expected-error {{use of undeclared label 'L2'}}
+ #pragma omp target
+ #pragma omp teams
+ L2:
+ foo();
+ #pragma omp target
+ #pragma omp teams
+ {
+ return 1; // expected-error {{cannot return from OpenMP region}}
+ }
+
+ [[]] // expected-error {{an attribute list cannot appear here}}
+ #pragma omp target
+ #pragma omp teams
+ for (int n = 0; n < 100; ++n) {}
+
+ return 0;
+}
+
diff --git a/clang/test/OpenMP/teams_private_messages.cpp b/clang/test/OpenMP/teams_private_messages.cpp
new file mode 100644
index 00000000000..c461b26e262
--- /dev/null
+++ b/clang/test/OpenMP/teams_private_messages.cpp
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+ return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+ mutable int a;
+public:
+ S2():a(0) { }
+ static float S2s; // expected-note {{static data member is predetermined as shared}}
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+ int a;
+public:
+ S3():a(0) { }
+};
+const S3 c; // expected-note {{global variable is predetermined as shared}}
+const S3 ca[5]; // expected-note {{global variable is predetermined as shared}}
+extern const int f; // expected-note {{global variable is predetermined as shared}}
+class S4 { // expected-note {{'S4' declared here}}
+ int a;
+ S4();
+public:
+ S4(int v):a(v) { }
+};
+class S5 { // expected-note {{'S5' declared here}}
+ int a;
+ S5():a(0) {}
+public:
+ S5(int v):a(v) { }
+};
+
+int threadvar;
+#pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}}
+
+int main(int argc, char **argv) {
+ const int d = 5; // expected-note {{constant variable is predetermined as shared}}
+ const int da[5] = { 0 }; // expected-note {{constant variable is predetermined as shared}}
+ S4 e(4); // expected-note {{'e' defined here}}
+ S5 g(5); // expected-note {{'g' defined here}}
+ int i;
+ int &j = i; // expected-note {{'j' defined here}}
+ #pragma omp target
+ #pragma omp teams private // expected-error {{expected '(' after 'private'}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private () // expected-error {{expected expression}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private (argc argv) // expected-error {{expected ',' or ')' in 'private' clause}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private (S1) // expected-error {{'S1' does not refer to a value}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private (argv[1]) // expected-error {{expected variable name}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private(ba)
+ foo();
+ #pragma omp target
+ #pragma omp teams private(ca) // expected-error {{shared variable cannot be private}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private(da) // expected-error {{shared variable cannot be private}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private(S2::S2s) // expected-error {{shared variable cannot be private}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private(threadvar) // expected-error {{threadprivate or thread local variable cannot be private}}
+ foo();
+ #pragma omp target
+ #pragma omp teams shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}}
+ foo();
+ #pragma omp target
+ #pragma omp teams firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private(i)
+ foo();
+ #pragma omp target
+ #pragma omp teams private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type 'int &'}}
+ foo();
+ #pragma omp target
+ #pragma omp teams firstprivate(i)
+ for (int k = 0; k < 10; ++k) {
+ #pragma omp parallel private(i)
+ foo();
+ }
+
+ return 0;
+}
diff --git a/clang/test/OpenMP/teams_reduction_messages.cpp b/clang/test/OpenMP/teams_reduction_messages.cpp
new file mode 100644
index 00000000000..afedfc3e46f
--- /dev/null
+++ b/clang/test/OpenMP/teams_reduction_messages.cpp
@@ -0,0 +1,307 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+ return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+ mutable int a;
+ S2 &operator+=(const S2 &arg) { return (*this); }
+
+public:
+ S2() : a(0) {}
+ S2(S2 &s2) : a(s2.a) {}
+ static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
+ static const float S2sc;
+};
+const float S2::S2sc = 0; // expected-note 2 {{'S2sc' defined here}}
+S2 b; // expected-note 2 {{'b' defined here}}
+const S2 ba[5]; // expected-note 2 {{'ba' defined here}}
+class S3 {
+ int a;
+
+public:
+ S3() : a(0) {}
+ S3(const S3 &s3) : a(s3.a) {}
+ S3 operator+=(const S3 &arg1) { return arg1; }
+};
+int operator+=(const S3 &arg1, const S3 &arg2) { return 5; }
+S3 c; // expected-note 2 {{'c' defined here}}
+const S3 ca[5]; // expected-note 2 {{'ca' defined here}}
+extern const int f; // expected-note 4 {{'f' declared here}}
+class S4 { // expected-note {{'S4' declared here}}
+ int a;
+ S4();
+ S4(const S4 &s4);
+ S4 &operator+=(const S4 &arg) { return (*this); }
+
+public:
+ S4(int v) : a(v) {}
+};
+S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
+class S5 {
+ int a;
+ S5() : a(0) {}
+ S5(const S5 &s5) : a(s5.a) {}
+ S5 &operator+=(const S5 &arg);
+
+public:
+ S5(int v) : a(v) {}
+};
+class S6 {
+ int a;
+
+public:
+ S6() : a(6) {}
+ operator int() { return 6; }
+} o; // expected-note 2 {{'o' defined here}}
+
+S3 h, k;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class T> // expected-note {{declared here}}
+T tmain(T argc) { // expected-note 2 {{'argc' defined here}}
+ const T d = T(); // expected-note 4 {{'d' defined here}}
+ const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
+ T qa[5] = {T()};
+ T i;
+ T &j = i; // expected-note 4 {{'j' defined here}}
+ S3 &p = k; // expected-note 2 {{'p' defined here}}
+ const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}}
+ T &q = qa[(int)i]; // expected-note 2 {{'q' defined here}}
+ T fl; // expected-note {{'fl' defined here}}
+#pragma omp target
+#pragma omp teams reduction // expected-error {{expected '(' after 'reduction'}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(&& : argc)
+ foo();
+#pragma omp target
+#pragma omp teams reduction(^ : T) // expected-error {{'T' does not refer to a value}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 3 {{const-qualified variable cannot be reduction}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified variable cannot be reduction}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(max : qa[1]) // expected-error 2 {{expected variable name}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}} expected-error {{a reduction variable with array type 'const float [5]'}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
+ foo();
+#pragma omp target
+#pragma omp teams private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+ foo();
+#pragma omp parallel private(k)
+#pragma omp target
+#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error 3 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 3 {{previously referenced here}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be reduction}}
+ foo();
+#pragma omp parallel shared(i)
+#pragma omp parallel reduction(min : i)
+#pragma omp target
+#pragma omp teams reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+ foo();
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for private(fl)
+ for (int i = 0; i < 10; ++i)
+#pragma omp target
+#pragma omp teams reduction(+ : fl)
+ foo();
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for reduction(- : fl)
+ for (int i = 0; i < 10; ++i)
+#pragma omp target
+#pragma omp teams reduction(+ : fl)
+ foo();
+
+ return T();
+}
+
+int main(int argc, char **argv) {
+ const int d = 5; // expected-note 2 {{'d' defined here}}
+ const int da[5] = {0}; // expected-note {{'da' defined here}}
+ int qa[5] = {0};
+ S4 e(4); // expected-note {{'e' defined here}}
+ S5 g(5); // expected-note {{'g' defined here}}
+ int i;
+ int &j = i; // expected-note 2 {{'j' defined here}}
+ S3 &p = k; // expected-note 2 {{'p' defined here}}
+ const int &r = da[i]; // expected-note {{'r' defined here}}
+ int &q = qa[i]; // expected-note {{'q' defined here}}
+ float fl; // expected-note {{'fl' defined here}}
+#pragma omp target
+#pragma omp teams reduction // expected-error {{expected '(' after 'reduction'}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(~ : argc) // expected-error {{expected unqualified-id}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(&& : argc)
+ foo();
+#pragma omp target
+#pragma omp teams reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{const-qualified variable cannot be reduction}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified variable cannot be reduction}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(max : argv[1]) // expected-error {{expected variable name}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(& : e, g) // expected-error {{reduction variable must have an accessible, unambiguous default constructor}} expected-error {{variable of type 'S5' is not valid for specified reduction operation}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
+ foo();
+#pragma omp target
+#pragma omp teams private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+ foo();
+#pragma omp parallel private(k)
+#pragma omp target
+#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
+ foo();
+#pragma omp target
+#pragma omp teams reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}
+ foo();
+#pragma omp parallel shared(i)
+#pragma omp parallel reduction(min : i)
+#pragma omp target
+#pragma omp teams reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+ foo();
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for private(fl)
+ for (int i = 0; i < 10; ++i)
+#pragma omp target
+#pragma omp teams reduction(+ : fl)
+ foo();
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for reduction(- : fl)
+ for (int i = 0; i < 10; ++i)
+#pragma omp target
+#pragma omp teams reduction(+ : fl)
+ foo();
+
+ return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}}
+}
diff --git a/clang/test/OpenMP/teams_shared_messages.cpp b/clang/test/OpenMP/teams_shared_messages.cpp
new file mode 100644
index 00000000000..ce2f917e207
--- /dev/null
+++ b/clang/test/OpenMP/teams_shared_messages.cpp
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+ return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+extern S1 a;
+class S2 {
+ mutable int a;
+public:
+ S2():a(0) { }
+ S2(S2 &s2):a(s2.a) { }
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+ int a;
+public:
+ S3():a(0) { }
+ S3(S3 &s3):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+ int a;
+ S4();
+ S4(const S4 &s4);
+public:
+ S4(int v):a(v) { }
+};
+class S5 {
+ int a;
+ S5():a(0) {}
+ S5(const S5 &s5):a(s5.a) { }
+public:
+ S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
+
+int main(int argc, char **argv) {
+ const int d = 5;
+ const int da[5] = { 0 };
+ S4 e(4);
+ S5 g(5);
+ int i;
+ int &j = i;
+ #pragma omp target
+ #pragma omp teams shared // expected-error {{expected '(' after 'shared'}}
+ foo();
+ #pragma omp target
+ #pragma omp teams shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target
+ #pragma omp teams shared () // expected-error {{expected expression}}
+ foo();
+ #pragma omp target
+ #pragma omp teams shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target
+ #pragma omp teams shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ foo();
+ #pragma omp target
+ #pragma omp teams shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+ foo();
+ #pragma omp target
+ #pragma omp teams shared (argc)
+ foo();
+ #pragma omp target
+ #pragma omp teams shared (S1) // expected-error {{'S1' does not refer to a value}}
+ foo();
+ #pragma omp target
+ #pragma omp teams shared (a, b, c, d, f)
+ foo();
+ #pragma omp target
+ #pragma omp teams shared (argv[1]) // expected-error {{expected variable name}}
+ foo();
+ #pragma omp target
+ #pragma omp teams shared(ba)
+ foo();
+ #pragma omp target
+ #pragma omp teams shared(ca)
+ foo();
+ #pragma omp target
+ #pragma omp teams shared(da)
+ foo();
+ #pragma omp target
+ #pragma omp teams shared(e, g)
+ foo();
+ #pragma omp target
+ #pragma omp teams shared(h) // expected-error {{threadprivate or thread local variable cannot be shared}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
+ foo();
+ #pragma omp target
+ #pragma omp teams firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
+ foo();
+ #pragma omp target
+ #pragma omp teams private(i)
+ foo();
+ #pragma omp target
+ #pragma omp teams shared(i)
+ foo();
+ #pragma omp target
+ #pragma omp teams shared(j)
+ foo();
+ #pragma omp target
+ #pragma omp teams firstprivate(i)
+ foo();
+ #pragma omp target
+ #pragma omp teams shared(i)
+ foo();
+ #pragma omp target
+ #pragma omp teams shared(j)
+ foo();
+
+ return 0;
+}
OpenPOWER on IntegriCloud