summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorcchen <cchen@cray.com>2019-12-04 14:36:07 -0500
committerAlexey Bataev <a.bataev@hotmail.com>2019-12-04 14:53:17 -0500
commit713dab21e27c987b9114547ce7136bac2e775de9 (patch)
tree696ff853d8c9db4fab6b73fbfcab6de0c4185d0d /clang/test
parent9e978bb01ceae8eaa415d8951cc96803e68b73fb (diff)
downloadbcm5719-llvm-713dab21e27c987b9114547ce7136bac2e775de9.tar.gz
bcm5719-llvm-713dab21e27c987b9114547ce7136bac2e775de9.zip
[OpenMP50] Add parallel master construct, by Chi Chun Chen.
Reviewers: ABataev, jdoerfert Reviewed By: ABataev Subscribers: jholewinski, guansong, arphaman, jfb, cfe-commits, sandoval, dreachem Tags: #clang Differential Revision: https://reviews.llvm.org/D70726
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/OpenMP/nesting_of_regions.cpp380
-rw-r--r--clang/test/OpenMP/parallel_master_ast_print.cpp222
-rw-r--r--clang/test/OpenMP/parallel_master_codegen.cpp471
-rw-r--r--clang/test/OpenMP/parallel_master_copyin_messages.cpp115
-rw-r--r--clang/test/OpenMP/parallel_master_default_messages.cpp41
-rw-r--r--clang/test/OpenMP/parallel_master_firstprivate_messages.cpp320
-rw-r--r--clang/test/OpenMP/parallel_master_if_messages.cpp173
-rw-r--r--clang/test/OpenMP/parallel_master_message.cpp88
-rw-r--r--clang/test/OpenMP/parallel_master_num_threads_messages.cpp67
-rw-r--r--clang/test/OpenMP/parallel_master_private_messages.cpp284
-rw-r--r--clang/test/OpenMP/parallel_master_proc_bind_messages.cpp30
-rw-r--r--clang/test/OpenMP/parallel_master_reduction_messages.cpp398
-rw-r--r--clang/test/OpenMP/parallel_master_shared_messages.cpp120
13 files changed, 2709 insertions, 0 deletions
diff --git a/clang/test/OpenMP/nesting_of_regions.cpp b/clang/test/OpenMP/nesting_of_regions.cpp
index 9aa7814c6c7..d80a06a8476 100644
--- a/clang/test/OpenMP/nesting_of_regions.cpp
+++ b/clang/test/OpenMP/nesting_of_regions.cpp
@@ -61,6 +61,11 @@ void foo() {
bar();
}
#pragma omp parallel
+#pragma omp parallel master
+ {
+ bar();
+ }
+#pragma omp parallel
#pragma omp task
{
bar();
@@ -301,6 +306,13 @@ void foo() {
}
#pragma omp simd
for (int i = 0; i < 10; ++i) {
+#pragma omp parallel master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ {
+ bar();
+ }
+ }
+#pragma omp simd
+ for (int i = 0; i < 10; ++i) {
#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
{
bar();
@@ -563,6 +575,13 @@ void foo() {
}
#pragma omp for
for (int i = 0; i < 10; ++i) {
+#pragma omp parallel master
+ {
+ bar();
+ }
+ }
+#pragma omp for
+ for (int i = 0; i < 10; ++i) {
#pragma omp parallel sections
{
bar();
@@ -809,6 +828,13 @@ void foo() {
}
#pragma omp for simd
for (int i = 0; i < 10; ++i) {
+#pragma omp parallel master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ {
+ bar();
+ }
+ }
+#pragma omp for simd
+ for (int i = 0; i < 10; ++i) {
#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
{
bar();
@@ -1045,6 +1071,13 @@ void foo() {
}
#pragma omp sections
{
+#pragma omp parallel master
+ {
+ bar();
+ }
+ }
+#pragma omp sections
+ {
#pragma omp parallel
{
#pragma omp master // OK
@@ -1321,6 +1354,16 @@ void foo() {
{
#pragma omp section
{
+#pragma omp parallel master
+ bar();
+#pragma omp critical
+ bar();
+ }
+ }
+#pragma omp sections
+ {
+#pragma omp section
+ {
#pragma omp single // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
bar();
#pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}}
@@ -1633,6 +1676,13 @@ void foo() {
}
#pragma omp single
{
+#pragma omp parallel master
+ {
+ bar();
+ }
+ }
+#pragma omp single
+ {
#pragma omp critical
{
bar();
@@ -1922,6 +1972,26 @@ void foo() {
}
#pragma omp master
{
+#pragma omp parallel master // OK
+ {
+ bar();
+ }
+#pragma omp parallel
+ {
+#pragma omp for // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp for simd // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp sections // OK
+ {
+ bar();
+ }
+ }
+ }
+#pragma omp master
+ {
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
;
@@ -2177,6 +2247,13 @@ void foo() {
}
#pragma omp critical
{
+#pragma omp parallel master
+ {
+ bar();
+ }
+ }
+#pragma omp critical
+ {
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
;
@@ -2910,6 +2987,281 @@ void foo() {
;
}
+// PARALLEL MASTER DIRECTIVE
+#pragma omp parallel master
+ {
+#pragma omp for // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp simd
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp parallel
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp single // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+ {
+ bar();
+ }
+ }
+#pragma omp parallel master
+ {
+#pragma omp master // OK, though second 'master' is redundant
+ {
+ bar();
+ }
+ }
+#pragma omp parallel master
+ {
+#pragma omp critical
+ {
+ bar();
+ }
+ }
+#pragma omp parallel master
+ {
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+ {
+ bar();
+ }
+ }
+#pragma omp parallel master
+ {
+#pragma omp parallel
+ {
+#pragma omp parallel master // OK
+ {
+ bar();
+ }
+#pragma omp for // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp for simd // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp sections // OK
+ {
+ bar();
+ }
+ }
+ }
+#pragma omp parallel master
+ {
+#pragma omp parallel master // OK
+ {
+ bar();
+ }
+#pragma omp parallel
+ {
+#pragma omp for // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp for simd // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+#pragma omp sections // OK
+ {
+ bar();
+ }
+ }
+ }
+#pragma omp parallel master
+ {
+#pragma omp parallel for
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp parallel for simd
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp parallel sections
+ {
+ bar();
+ }
+ }
+#pragma omp parallel master
+ {
+#pragma omp task
+ {
+ bar();
+ }
+ }
+#pragma omp parallel master
+ {
+#pragma omp taskyield
+ bar();
+ }
+#pragma omp parallel master
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel master' region}}
+ bar();
+ }
+#pragma omp parallel master
+ {
+#pragma omp taskwait
+ bar();
+ }
+#pragma omp parallel master
+ {
+#pragma omp flush
+ bar();
+ }
+#pragma omp parallel master
+ {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+ bar();
+ }
+#pragma omp parallel master
+ {
+#pragma omp atomic
+ ++a;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target
+ ++a;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target parallel
+ ++a;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target parallel for
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target enter data map(to: a)
+ ++a;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target exit data map(from: a)
+ ++a;
+ }
+#pragma omp parallel master
+ {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+ ++a;
+ }
+#pragma omp parallel master
+ {
+#pragma omp taskloop
+ for (int i = 0; i < 10; ++i)
+ ++a;
+ }
+#pragma omp parallel master
+ {
+#pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target update to(a)
+ bar();
+ }
+#pragma omp parallel master
+ {
+#pragma omp distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp distribute parallel for' directive into a teams region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp distribute parallel for simd // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp distribute parallel for simd' directive into a teams region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp distribute simd // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp distribute simd' directive into a teams region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target simd // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp teams distribute // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp teams distribute' directive into a target region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp teams distribute simd // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp teams distribute simd' directive into a target region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp teams distribute parallel for simd // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp teams distribute parallel for simd' directive into a target region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp teams distribute parallel for // expected-error {{region cannot be closely nested inside 'parallel master' region; perhaps you forget to enclose 'omp teams distribute parallel for' directive into a target region?}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target teams // OK
+ a++;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target teams distribute // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target teams distribute parallel for // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target teams distribute parallel for simd // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp parallel master
+ {
+#pragma omp target teams distribute simd // OK
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
{
@@ -3722,6 +4074,15 @@ void foo() {
// expected-error@+2 {{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}}
// expected-note@+1 {{expected an expression statement}}
{
+#pragma omp parallel master // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ // expected-error@+2 {{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}}
+ // expected-note@+1 {{expected an expression statement}}
+ {
#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
{
bar();
@@ -4237,6 +4598,11 @@ void foo() {
{
bar();
}
+#pragma omp target
+#pragma omp parallel master
+ {
+ bar();
+ }
#pragma omp target parallel
#pragma omp critical
{
@@ -9000,6 +9366,8 @@ void foo() {
#pragma omp parallel
#pragma omp master
bar();
+#pragma omp parallel master
+ bar();
#pragma omp parallel
#pragma omp critical
bar();
@@ -10760,6 +11128,11 @@ void foo() {
for (int i = 0; i < 10; ++i)
;
}
+#pragma omp parallel master
+ {
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
#pragma omp master
{
#pragma omp single // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
@@ -10810,6 +11183,13 @@ void foo() {
}
#pragma omp master
{
+#pragma omp parallel master
+ {
+ bar();
+ }
+ }
+#pragma omp master
+ {
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
;
diff --git a/clang/test/OpenMP/parallel_master_ast_print.cpp b/clang/test/OpenMP/parallel_master_ast_print.cpp
new file mode 100644
index 00000000000..0e07258a73c
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_ast_print.cpp
@@ -0,0 +1,222 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+struct S1 {
+ S1(): a(0) {}
+ S1(int v) : a(v) {}
+ int a;
+ typedef int type;
+ S1& operator +(const S1&);
+ S1& operator *(const S1&);
+ S1& operator &&(const S1&);
+ S1& operator ^(const S1&);
+};
+
+template <typename T>
+class S7 : public T {
+protected:
+ T a;
+ T b[100];
+ S7() : a(0) {}
+
+public:
+ S7(typename T::type v) : a(v) {
+#pragma omp parallel master private(a) private(this->a) private(T::a)
+ for (int k = 0; k < a.a; ++k)
+ ++this->a.a;
+#pragma omp parallel master firstprivate(a) firstprivate(this->a) firstprivate(T::a)
+ for (int k = 0; k < a.a; ++k)
+ ++this->a.a;
+#pragma omp parallel master shared(a) shared(this->a) shared(T::a)
+ for (int k = 0; k < a.a; ++k)
+ ++this->a.a;
+#pragma omp parallel master reduction(+ : a) reduction(*: b[:])
+ for (int k = 0; k < a.a; ++k)
+ ++this->a.a;
+ }
+ S7 &operator=(S7 &s) {
+#pragma omp parallel master private(a) private(this->a)
+ for (int k = 0; k < s.a.a; ++k)
+ ++s.a.a;
+#pragma omp parallel master firstprivate(a) firstprivate(this->a)
+ for (int k = 0; k < s.a.a; ++k)
+ ++s.a.a;
+#pragma omp parallel master shared(a) shared(this->a)
+ for (int k = 0; k < s.a.a; ++k)
+ ++s.a.a;
+#pragma omp parallel master reduction(&& : this->a) reduction(^: b[s.a.a])
+ for (int k = 0; k < s.a.a; ++k)
+ ++s.a.a;
+ return *this;
+ }
+};
+
+// CHECK: #pragma omp parallel master private(this->a) private(this->a) private(T::a)
+// CHECK: #pragma omp parallel master firstprivate(this->a) firstprivate(this->a) firstprivate(T::a)
+// CHECK: #pragma omp parallel master shared(this->a) shared(this->a) shared(T::a)
+// CHECK: #pragma omp parallel master reduction(+: this->a) reduction(*: this->b[:])
+// CHECK: #pragma omp parallel master private(this->a) private(this->a)
+// CHECK: #pragma omp parallel master firstprivate(this->a) firstprivate(this->a)
+// CHECK: #pragma omp parallel master shared(this->a) shared(this->a)
+// CHECK: #pragma omp parallel master reduction(&&: this->a) reduction(^: this->b[s.a.a])
+// CHECK: #pragma omp parallel master private(this->a) private(this->a) private(this->S1::a)
+// CHECK: #pragma omp parallel master firstprivate(this->a) firstprivate(this->a) firstprivate(this->S1::a)
+// CHECK: #pragma omp parallel master shared(this->a) shared(this->a) shared(this->S1::a)
+// CHECK: #pragma omp parallel master reduction(+: this->a) reduction(*: this->b[:])
+
+class S8 : public S7<S1> {
+ S8() {}
+
+public:
+ S8(int v) : S7<S1>(v){
+#pragma omp parallel master private(a) private(this->a) private(S7 < S1 > ::a)
+ for (int k = 0; k < a.a; ++k)
+ ++this->a.a;
+#pragma omp parallel master firstprivate(a) firstprivate(this->a) firstprivate(S7 < S1 > ::a)
+ for (int k = 0; k < a.a; ++k)
+ ++this->a.a;
+#pragma omp parallel master shared(a) shared(this->a) shared(S7 < S1 > ::a)
+ for (int k = 0; k < a.a; ++k)
+ ++this->a.a;
+#pragma omp parallel master reduction(^ : S7 < S1 > ::a) reduction(+ : S7 < S1 > ::b[ : S7 < S1 > ::a.a])
+ for (int k = 0; k < a.a; ++k)
+ ++this->a.a;
+ }
+ S8 &operator=(S8 &s) {
+#pragma omp parallel master private(a) private(this->a)
+ for (int k = 0; k < s.a.a; ++k)
+ ++s.a.a;
+#pragma omp parallel master firstprivate(a) firstprivate(this->a)
+ for (int k = 0; k < s.a.a; ++k)
+ ++s.a.a;
+#pragma omp parallel master shared(a) shared(this->a)
+ for (int k = 0; k < s.a.a; ++k)
+ ++s.a.a;
+#pragma omp parallel master reduction(* : this->a) reduction(&&:this->b[a.a:])
+ for (int k = 0; k < s.a.a; ++k)
+ ++s.a.a;
+ return *this;
+ }
+};
+
+// CHECK: #pragma omp parallel master private(this->a) private(this->a) private(this->S7<S1>::a)
+// CHECK: #pragma omp parallel master firstprivate(this->a) firstprivate(this->a) firstprivate(this->S7<S1>::a)
+// CHECK: #pragma omp parallel master shared(this->a) shared(this->a) shared(this->S7<S1>::a)
+// CHECK: #pragma omp parallel master reduction(^: this->S7<S1>::a) reduction(+: this->S7<S1>::b[:this->S7<S1>::a.a])
+// CHECK: #pragma omp parallel master private(this->a) private(this->a)
+// CHECK: #pragma omp parallel master firstprivate(this->a) firstprivate(this->a)
+// CHECK: #pragma omp parallel master shared(this->a) shared(this->a)
+// CHECK: #pragma omp parallel master reduction(*: this->a) reduction(&&: this->b[this->a.a:])
+
+template <class T>
+struct S {
+ operator T() {return T();}
+ static T TS;
+ #pragma omp threadprivate(TS)
+};
+
+// CHECK: template <class T> struct S {
+// CHECK: static T TS;
+// CHECK-NEXT: #pragma omp threadprivate(S::TS)
+// CHECK: };
+// CHECK: template<> struct S<int> {
+// CHECK: static int TS;
+// CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
+// CHECK-NEXT: }
+// CHECK: template<> struct S<long> {
+// CHECK: static long TS;
+// CHECK-NEXT: #pragma omp threadprivate(S<long>::TS)
+// CHECK-NEXT: }
+
+int thrp;
+#pragma omp threadprivate(thrp)
+
+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;
+ T arr[C][10], arr1[C];
+#pragma omp parallel master
+ a=2;
+#pragma omp parallel master default(none), private(argc,b) firstprivate(argv) shared (d) if (parallel:argc > 0) num_threads(C) copyin(S<T>::TS, thrp) proc_bind(master) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10])
+ foo();
+#pragma omp parallel master if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(&& : g)
+ foo();
+ return 0;
+}
+
+// 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: T arr[C][10], arr1[C];
+// CHECK-NEXT: #pragma omp parallel master{{$}}
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp parallel master default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S<T>::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10])
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp parallel master if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(&&: g)
+// CHECK-NEXT: foo()
+// CHECK: template<> int tmain<int, 5>(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: int arr[5][10], arr1[5];
+// CHECK-NEXT: #pragma omp parallel master
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp parallel master default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) copyin(S<int>::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:5][0:10])
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp parallel master if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(&&: g)
+// CHECK-NEXT: foo()
+// CHECK: template<> long tmain<long, 1>(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: long arr[1][10], arr1[1];
+// CHECK-NEXT: #pragma omp parallel master
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp parallel master default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) copyin(S<long>::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:1][0:10])
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp parallel master if(1) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:1][:argc]) 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)
+ int arr[10][argc], arr1[2];
+ Enum ee;
+// CHECK: Enum ee;
+#pragma omp parallel master
+// CHECK-NEXT: #pragma omp parallel master
+ a=2;
+// CHECK-NEXT: a = 2;
+#pragma omp parallel master default(none), private(argc,b) firstprivate(argv) if (parallel: argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(| : c, d, arr1[argc]) reduction(* : e, arr[:10][0:argc]) allocate(e)
+// CHECK-NEXT: #pragma omp parallel master default(none) private(argc,b) firstprivate(argv) if(parallel: argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(|: c,d,arr1[argc]) reduction(*: e,arr[:10][0:argc]) allocate(e)
+ foo();
+// CHECK-NEXT: foo();
+// CHECK-NEXT: #pragma omp parallel master allocate(e) if(b) num_threads(c) proc_bind(close) reduction(^: e,f) reduction(&&: g,arr[0:argc][:10])
+// CHECK-NEXT: foo()
+#pragma omp parallel master allocate(e) if (b) num_threads(c) proc_bind(close) reduction(^:e, f) reduction(&& : g, arr[0:argc][:10])
+ foo();
+ return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
+}
+
+template<typename T>
+T S<T>::TS = 0;
+
+#endif
diff --git a/clang/test/OpenMP/parallel_master_codegen.cpp b/clang/test/OpenMP/parallel_master_codegen.cpp
new file mode 100644
index 00000000000..710d4dce81b
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_codegen.cpp
@@ -0,0 +1,471 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+#ifdef CK1
+///==========================================================================///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK1
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// CK1-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK1-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CK1-DAG: [[DEF_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+// CK1-LABEL: foo
+void foo() {}
+
+void parallel_master() {
+#pragma omp parallel master
+ foo();
+}
+
+// CK1-LABEL: define void @{{.+}}parallel_master{{.+}}
+// CK1: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC]], i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*))
+
+// CK1: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias %.global_tid., i32* noalias %.bound_tid.)
+// CK1-NOT: __kmpc_global_thread_num
+// CK1: call i32 @__kmpc_master({{.+}})
+// CK1: invoke void {{.*}}foo{{.*}}()
+// CK1-NOT: __kmpc_global_thread_num
+// CK1: call void @__kmpc_end_master({{.+}})
+// CK1: call void @__clang_call_terminate
+// CK1: unreachable
+
+#endif
+
+#ifdef CK2
+///==========================================================================///
+// RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK2
+// RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2
+
+// RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// CK2-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK2-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CK2-DAG: [[DEF_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+void parallel_master_private() {
+ int a;
+#pragma omp parallel master private(a)
+ a++;
+}
+
+// CK2-LABEL: define void @{{.+}}parallel_master_private{{.+}}
+// CK2: [[A_PRIV:%.+]] = alloca i32
+// CK2: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC]], i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*))
+
+// CK2: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias %.global_tid., i32* noalias %.bound_tid.)
+// CK2-NOT: __kmpc_global_thread_num
+// CK2: call i32 @__kmpc_master({{.+}})
+// CK2: [[A_VAL:%.+]] = load i32, i32* [[A_PRIV]]
+// CK2: [[INC:%.+]] = add nsw i32 [[A_VAL]]
+// CK2: store i32 [[INC]], i32* [[A_PRIV]]
+// CK2-NOT: __kmpc_global_thread_num
+// CK2: call void @__kmpc_end_master({{.+}})
+// CK2: ret void
+
+#endif
+
+#ifdef CK3
+///==========================================================================///
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK3
+// RUN: %clang_cc1 -DCK3 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK3 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK3
+
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// CK3-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK3-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+
+void parallel_master_private() {
+ int a;
+#pragma omp parallel master default(shared)
+ a++;
+}
+
+// CK3-LABEL: define void @{{.+}}parallel_master{{.+}}
+// CK3: [[A_VAL:%.+]] = alloca i32
+// CK3: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void
+
+// CK3: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias %.global_tid., i32* noalias %.bound_tid., i32* dereferenceable(4) [[A_VAL]])
+// CK3: %.global_tid..addr = alloca i32*
+// CK3: %.bound_tid..addr = alloca i32*
+// CK3: [[A_ADDR:%.+]] = alloca i32*
+// CK3: store i32* %.global_tid., i32** %.global_tid..addr
+// CK3: store i32* %.bound_tid., i32** %.bound_tid..addr
+// CK3: store i32* [[A_VAL]], i32** [[A_ADDR]]
+// CK3: [[ZERO:%.+]] = load i32*, i32** [[A_ADDR]]
+// CK3-NOT: __kmpc_global_thread_num
+// CK3: call i32 @__kmpc_master({{.+}})
+// CK3: [[FIVE:%.+]] = load i32, i32* [[ZERO]]
+// CK3: [[INC:%.+]] = add nsw i32 [[FIVE]]
+// CK3: store i32 [[INC]], i32* [[ZERO]]
+// CK3-NOT: __kmpc_global_thread_num
+// CK3: call void @__kmpc_end_master({{.+}})
+
+#endif
+
+#ifdef CK4
+///==========================================================================///
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK4
+// RUN: %clang_cc1 -DCK4 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK4 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK4
+
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK4 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK4 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// CK4-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK4-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CK4-DAG: [[DEF_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+void parallel_master_firstprivate() {
+ int a;
+#pragma omp parallel master firstprivate(a)
+ a++;
+}
+
+// CK4-LABEL: define void @{{.+}}parallel_master_firstprivate{{.+}}
+// CK4: [[A_VAL:%.+]] = alloca i32
+// CK4: [[A_CASTED:%.+]] = alloca i64
+// CK4: [[ZERO:%.+]] = load i32, i32* [[A_VAL]]
+// CK4: [[CONV:%.+]] = bitcast i64* [[A_CASTED]] to i32*
+// CK4: store i32 [[ZERO]], i32* [[CONV]]
+// CK4: [[ONE:%.+]] = load i64, i64* [[A_CASTED]]
+// CK4: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 [[ONE]])
+
+// CK4: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GLOBAL_TID:%.+]], i32* noalias [[BOUND_TID:%.+]], i64 [[A_VAL]])
+// CK4: [[GLOBAL_TID_ADDR:%.+]] = alloca i32*
+// CK4: [[BOUND_TID_ADDR:%.+]] = alloca i32*
+// CK4: [[A_ADDR:%.+]] = alloca i64
+// CK4: store i32* [[GLOBAL_TID]], i32** [[GLOBAL_TID_ADDR]]
+// CK4: store i32* [[BOUND_TID]], i32** [[BOUND_TID_ADDR]]
+// CK4: store i64 [[A_VAL]], i64* [[A_ADDR]]
+// CK4: [[CONV]] = bitcast i64* [[A_ADDR]] to i32*
+// CK4-NOT: __kmpc_global_thread_num
+// CK4: call i32 @__kmpc_master({{.+}})
+// CK4: [[FOUR:%.+]] = load i32, i32* [[CONV]]
+// CK4: [[INC:%.+]] = add nsw i32 [[FOUR]]
+// CK4: store i32 [[INC]], i32* [[CONV]]
+// CK4-NOT: __kmpc_global_thread_num
+// CK4: call void @__kmpc_end_master({{.+}})
+
+#endif
+
+#ifdef CK5
+///==========================================================================///
+// RUN: %clang_cc1 -DCK5 -verify -fopenmp -fopenmp -fnoopenmp-use-tls -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK5
+// RUN: %clang_cc1 -DCK5 -fopenmp -fopenmp -fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK5 -fopenmp -fopenmp -fnoopenmp-use-tls -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK5
+
+// RUN: %clang_cc1 -DCK5 -verify -fopenmp-simd -fnoopenmp-use-tls -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK5 -fopenmp-simd -fnoopenmp-use-tls -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK5 -fopenmp-simd -fnoopenmp-use-tls -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// RUN: %clang_cc1 -DCK5 -verify -fopenmp -x c++ -triple x86_64-linux -emit-llvm %s -o - | FileCheck %s -check-prefix=TLS-CHECK
+// RUN: %clang_cc1 -DCK5 -fopenmp -x c++ -std=c++11 -triple x86_64-linux -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK5 -fopenmp -x c++ -triple x86_64-linux -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TLS-CHECK
+
+// RUN: %clang_cc1 -DCK5 -verify -fopenmp-simd -x c++ -triple x86_64-linux -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK5 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-linux -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK5 -fopenmp-simd -x c++ -triple x86_64-linux -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+
+// CK5-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK5-DAG: [[A:@.+]] = {{.+}} i32 0
+// CK5-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CK5-DAG: [[DEF_LOC_1:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+// CK5-DAG: [[A_CACHE:@.+]] = common global i8** null
+// CK5-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 66, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+// TLS-CHECK-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// TLS-CHECK-DAG: [[A:@.+]] = thread_local global i32 0
+// TLS-CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// TLS-CHECK-DAG: [[DEF_LOC_1:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 66, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+// TLS-CHECK-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+int a;
+#pragma omp threadprivate(a)
+
+void parallel_master_copyin() {
+#pragma omp parallel master copyin(a)
+ a++;
+}
+
+// CK5-LABEL: define void @{{.+}}parallel_master_copyin{{.+}}
+// CK5: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_1]], i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*))
+// CK5: ret void
+// TLS-CHECK-LABEL: define void @{{.+}}parallel_master_copyin{{.+}}
+// TLS-CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*)
+// TLS-CHECK: ret void
+
+// CK5: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GLOBAL_TID:%.+]], i32* noalias [[BOUND_TID:%.+]])
+// CK5: [[GLOBAL_TID_ADDR:%.+]] = alloca i32*
+// CK5: [[BOUND_TID_ADDR:%.+]] = alloca i32*
+// CK5: store i32* [[GLOBAL_TID]], i32** [[GLOBAL_TID_ADDR]]
+// CK5: store i32* [[BOUND_TID]], i32** [[BOUND_TID_ADDR]]
+// CK5: [[ZERO:%.+]] = load i32*, i32** [[GLOBAL_TID_ADDR]]
+// CK5: [[ONE:%.+]] = load i32, i32* [[ZERO]]
+// CK5: [[TWO:%.+]] = call i8* @__kmpc_threadprivate_cached(%struct.ident_t* [[DEF_LOC_1]], i32 [[ONE]], i8* bitcast (i32* [[A]] to i8*), i64 4, i8*** [[A_CACHE]])
+// CK5: [[THREE:%.+]] = bitcast i8* [[TWO]] to i32*
+// CK5: [[FOUR:%.+]] = ptrtoint i32* [[THREE]] to i64
+// CK5: [[FIVE:%.+]] = icmp ne i64 ptrtoint (i32* [[A]] to i64), [[FOUR]]
+// CK5: br i1 [[FIVE]], label [[COPYIN_NOT_MASTER:%.+]], label [[COPYIN_NOT_MASTER_END:%.+]]
+// TLS-CHECK: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GLOBAL_TID:%.+]], i32* noalias [[BOUND_TID:%.+]], i32* {{.+}} [[A_VAR:%.+]])
+// TLS-CHECK: [[GLOBAL_TID_ADDR:%.+]] = alloca i32*
+// TLS-CHECK: [[BOUND_TID_ADDR:%.+]] = alloca i32*
+// TLS-CHECK: [[A_ADDR:%.+]] = alloca i32*
+// TLS-CHECK: store i32* [[A_VAR]], i32** [[A_ADDR]]
+// TLS-CHECK: [[ZERO:%.+]] = load i32*, i32** [[A_ADDR]]
+// TLS-CHECK: [[ONE:%.+]] = ptrtoint i32* [[ZERO]] to i64
+// TLS-CHECK: [[TWO:%.+]] = icmp ne i64 [[ONE]], ptrtoint (i32* [[A]] to i64)
+// TLS-CHECK: br i1 [[TWO]], label [[COPYIN_NOT_MASTER:%.+]], label [[COPYIN_NOT_MASTER_END:%.+]]
+
+// CK5-DAG: [[COPYIN_NOT_MASTER]]
+// CK5-DAG: [[SIX:%.+]] = load i32, i32* [[A]]
+// TLS-CHECK-DAG: [[COPYIN_NOT_MASTER]]
+// TLS-CHECK-DAG: [[THREE:%.+]] = load i32, i32* [[ZERO]]
+// TLS-CHECK-DAG: store i32 [[THREE]], i32* [[A]]
+
+// CK5-DAG: [[COPYIN_NOT_MASTER_END]]
+// CK5-DAG: call void @__kmpc_barrier(%struct.ident_t* [[DEF_LOC_2]], i32 [[ONE]])
+// CK5-DAG: [[SEVEN:%.+]] = call i32 @__kmpc_master(%struct.ident_t* [[DEF_LOC_1]], i32 [[ONE]])
+// CK5-DAG: [[EIGHT:%.+]] = icmp ne i32 [[SEVEN]], 0
+// CK5-DAG: br i1 %8, label [[OMP_IF_THEN:%.+]], label [[OMP_IF_END:%.+]]
+// TLS-CHECK-DAG: [[FOUR:%.+]] = load i32*, i32** [[GLOBAL_TID_ADDR:%.+]]
+// TLS-CHECK-DAG: [[FIVE:%.+]] = load i32, i32* [[FOUR]]
+// TLS-CHECK-DAG: call void @__kmpc_barrier(%struct.ident_t* [[DEF_LOC_1]], i32 [[FIVE]])
+// TLS-CHECK-DAG: [[SIX:%.+]] = load i32*, i32** [[GLOBAL_TID_ADDR]]
+// TLS-CHECK-DAG: [[SEVEN:%.+]] = load i32, i32* [[SIX]]
+// TLS-CHECK-DAG: [[EIGHT:%.+]] = call i32 @__kmpc_master(%struct.ident_t* [[DEF_LOC_2]], i32 [[SEVEN]])
+// TLS-CHECK-DAG: [[NINE:%.+]] = icmp ne i32 [[EIGHT]], 0
+// TLS-CHECK-DAG: br i1 [[NINE]], label [[OMP_IF_THEN:%.+]], label [[OMP_IF_END:%.+]]
+
+// CK5-DAG: [[OMP_IF_THEN]]
+// CK5-DAG: [[NINE:%.+]] = call i8* @__kmpc_threadprivate_cached(%struct.ident_t* [[DEF_LOC_1]], i32 %1, i8* bitcast (i32* [[A]] to i8*), i64 4, i8*** [[A_CACHE]])
+// CK5-DAG: [[TEN:%.+]] = bitcast i8* [[NINE]] to i32*
+// CK5-DAG: [[ELEVEN:%.+]] = load i32, i32* [[TEN]]
+// CK5-DAG: [[INC:%.+]] = add nsw i32 [[ELEVEN]], 1
+// CK5-DAG: store i32 [[INC]], i32* [[TEN]]
+// CK5-DAG: call void @__kmpc_end_master(%struct.ident_t* [[DEF_LOC_1]], i32 [[ONE]])
+// CK5-DAG: [[OMP_IF_END]]
+// CK5-DAG: ret void
+
+// TLS-CHECK-DAG: [[OMP_IF_THEN]]
+// TLS-CHECK-DAG: [[TEN:%.+]] = load i32, i32* [[A]]
+// TLC-CHECK-DAG: %inc = add nsw i32 [[TEN]], 1
+// TLS-CHECK-DAG: store i32 %inc, i32* [[A]]
+// TLS-CHECK-DAG: call void @__kmpc_end_master(%struct.ident_t* [[DEF_LOC_2]], i32 [[SEVEN]])
+// TLS-CHECK-DAG: [[OMP_IF_END]]
+// TLS-CHECK-DAG: ret void
+
+#endif
+#ifdef CK6
+///==========================================================================///
+// RUN: %clang_cc1 -DCK6 -verify -fopenmp -x c++ -triple x86_64-linux -emit-llvm %s -o - | FileCheck %s -check-prefix=CK6
+// RUN: %clang_cc1 -DCK6 -fopenmp -x c++ -std=c++11 -triple x86_64-linux -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK6 -fopenmp -x c++ -triple x86_64-linux -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=CK6
+
+// RUN: %clang_cc1 -DCK6 -verify -fopenmp-simd -x c++ -triple x86_64-linux -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK6 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-linux -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK6 -fopenmp-simd -x c++ -triple x86_64-linux -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+
+// CK6-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK6-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CK6-DAG: [[DEF_LOC_1:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+// CK6-DAG: [[GOMP:@.+]] = common global [8 x i32] zeroinitializer
+// CK6-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 18, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+void parallel_master_reduction() {
+ int g;
+#pragma omp parallel master reduction(+:g)
+ g = 1;
+}
+
+// CK6-LABEL: define void @{{.+}}parallel_master_reduction{{.+}}
+// CK6: [[G_VAR:%.+]] = alloca i32
+// CK6: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_1]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i32* [[G_VAR]])
+// CK6: ret void
+
+// CK6: define internal void [[OMP_OUTLINED]](i32* noalias [[GLOBAL_TID:%.+]], i32* noalias [[BOUND_TID:%.+]], i32* {{.+}} [[G_VAR]])
+// CK6: %.global_tid..addr = alloca i32*
+// CK6: %.bound_tid..addr = alloca i32*
+// CK6: [[G_ADDR:%.+]] = alloca i32*
+// CK6: [[G_1:%.+]] = alloca i32
+// CK6: [[RED_LIST:%.+]] = alloca [1 x i8*]
+// CK6: [[ZERO:%.+]] = load i32*, i32** [[G_ADDR]]
+// CK6: [[ONE:%.+]] = load i32*, i32** %.global_tid..addr
+// CK6: [[TWO:%.+]] = load i32, i32* [[ONE]]
+// CK6: [[THREE:%.+]] = call i32 @__kmpc_master(%struct.ident_t* [[DEF_LOC_1]], i32 [[TWO]])
+// CK6: [[FOUR:%.+]] = icmp ne i32 [[THREE]]
+
+// CK6: store i32 1, i32* [[G_1]]
+// CK6: call void @__kmpc_end_master(%struct.ident_t* [[DEF_LOC_1]], i32 [[TWO]])
+
+// CK6: [[FIVE:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[RED_LIST]], i64 0, i64 0
+// CK6: [[SEVEN:%.+]] = bitcast [1 x i8*]* [[RED_LIST]] to i8*
+// CK6: [[EIGHT:%.+]] = call i32 @__kmpc_reduce_nowait(%struct.ident_t* [[DEF_LOC_2]], i32 [[TWO]], i32 1, i64 8, i8* [[SEVEN]], void (i8*, i8*)* [[RED_FUNC:@.+]], [8 x i32]* [[RED_VAR:@.+]])
+
+// switch
+// CK6: switch i32 [[EIGHT]], label [[RED_DEFAULT:%.+]] [
+// CK6: i32 1, label [[CASE1:%.+]]
+// CK6: i32 2, label [[CASE2:%.+]]
+
+// case 1:
+// CK6: [[NINE:%.+]] = load i32, i32* %0, align 4
+// CK6: [[TEN:%.+]] = load i32, i32* [[G_1]]
+// CK6: [[ADD:%.+]] = add nsw i32 [[NINE]], [[TEN]]
+// CK6: store i32 [[ADD]], i32* [[ZERO]]
+// CK6: call void @__kmpc_end_reduce_nowait(%struct.ident_t* [[DEF_LOC_2]], i32 [[TWO]], [8 x i32]* [[GOMP]])
+// CK6: br label [[RED_DEFAULT]]
+
+// case 2:
+// CK6: [[ELEVEN:%.+]] = load i32, i32* [[G_1]]
+// CK6: [[TWELVE:%.+]] = atomicrmw add i32* [[ZERO]], i32 [[ELEVEN]] monotonic
+
+// CK6: define internal void [[RED_FUNC]](i8* [[ZERO]], i8* [[ONE]])
+// CK6: ret void
+#endif
+#ifdef CK7
+///==========================================================================///
+// RUN: %clang_cc1 -DCK7 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK7
+// RUN: %clang_cc1 -DCK7 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK7 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK7
+
+// RUN: %clang_cc1 -DCK7 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK7 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK7 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// CK7-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK7-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CK7-DAG: [[DEF_LOC_1:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+void parallel_master_if() {
+#pragma omp parallel master if (parallel: false)
+ parallel_master_if();
+}
+
+// CK7-LABEL: parallel_master_if
+// CK7: [[ZERO:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* [[DEF_LOC_1]])
+// CK7: call void @__kmpc_serialized_parallel(%struct.ident_t* [[DEF_LOC_1]], i32 [[ZERO]])
+// CK7: call void [[OUTLINED:@.+]](i32* [[THREAD_TEMP:%.+]], i32* [[BND_ADDR:%.+]])
+// CK7: call void @__kmpc_end_serialized_parallel(%struct.ident_t* [[DEF_LOC_1]], i32 [[ZERO]])
+// CK7: ret void
+
+// CK7: define internal void @.omp_outlined.(i32* noalias [[GTID:%.+]], i32* noalias [[BTID:%.+]])
+// CK7: [[EXECUTE:%.+]] = call i32 @__kmpc_master(%struct.ident_t* @0, i32 %1)
+// CK7: call void @__kmpc_end_master(%struct.ident_t* [[DEF_LOC_1]], i32 %1)
+
+#endif
+#ifdef CK8
+///==========================================================================///
+// RUN: %clang_cc1 -DCK8 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK8
+// RUN: %clang_cc1 -DCK8 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK8 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK8
+
+// RUN: %clang_cc1 -DCK8 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK8 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK8 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+typedef __INTPTR_TYPE__ intptr_t;
+
+// CK8-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
+// CK8-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CK8-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global [[IDENT_T_TY]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+void foo();
+
+struct S {
+ intptr_t a, b, c;
+ S(intptr_t a) : a(a) {}
+ operator char() { return a; }
+ ~S() {}
+};
+
+template <typename T>
+T tmain() {
+#pragma omp parallel master proc_bind(master)
+ foo();
+ return T();
+}
+
+int main() {
+#pragma omp parallel master proc_bind(spread)
+ foo();
+#pragma omp parallel master proc_bind(close)
+ foo();
+ return tmain<int>();
+}
+
+// CK8-LABEL: @main
+// CK8: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]])
+// CK8: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 4)
+// CK8: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+// CK8: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 3)
+// CK8: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+
+// CK8-LABEL: @{{.+}}tmain
+// CK8: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]])
+// CK8: call {{.*}}void @__kmpc_push_proc_bind([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 2)
+// CK8: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+// CK8: ret i32 0
+// CK8-NEXT: }
+
+// CK8: call i32 @__kmpc_master(%struct.ident_t* [[DEF_LOC_2]], i32 [[ONE:%.+]])
+// CK8: call void @__kmpc_end_master(%struct.ident_t* [[DEF_LOC_2]], i32 [[ONE]])
+
+#endif
+#ifdef CK9
+// CK9-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK9-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CK9-DAG: [[DEF_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+void parallel_master_firstprivate() {
+ int a;
+#pragma omp parallel master firstprivate(a) allocate(a)
+ a++;
+}
+
+// CK9-LABEL: define void @{{.+}}parallel_master_firstprivate{{.+}}
+// CK9: [[A_VAL:%.+]] = alloca i32
+// CK9: [[A_CASTED:%.+]] = alloca i64
+// CK9: [[ZERO:%.+]] = load i32, i32* [[A_VAL]]
+// CK9: [[CONV:%.+]] = bitcast i64* [[A_CASTED]] to i32*
+// CK9: store i32 [[ZERO]], i32* [[CONV]]
+// CK9: [[ONE:%.+]] = load i64, i64* [[A_CASTED]]
+// CK9: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 [[ONE]])
+
+// CK9: define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias [[GLOBAL_TID:%.+]], i32* noalias [[BOUND_TID:%.+]], i64 [[A_VAL]])
+// CK9: [[GLOBAL_TID_ADDR:%.+]] = alloca i32*
+// CK9: [[BOUND_TID_ADDR:%.+]] = alloca i32*
+// CK9: [[A_ADDR:%.+]] = alloca i64
+// CK9: store i32* [[GLOBAL_TID]], i32** [[GLOBAL_TID_ADDR]]
+// CK9: store i32* [[BOUND_TID]], i32** [[BOUND_TID_ADDR]]
+// CK9: store i64 [[A_VAL]], i64* [[A_ADDR]]
+// CK9: [[CONV]] = bitcast i64* [[A_ADDR]] to i32*
+// CK9-NOT: __kmpc_global_thread_num
+// CK9: call i32 @__kmpc_master({{.+}})
+// CK9: [[FOUR:%.+]] = load i32, i32* [[CONV]]
+// CK9: [[INC:%.+]] = add nsw i32 [[FOUR]]
+// CK9: store i32 [[INC]], i32* [[CONV]]
+// CK9-NOT: __kmpc_global_thread_num
+// CK9: call void @__kmpc_end_master({{.+}})
+#endif
+#endif
diff --git a/clang/test/OpenMP/parallel_master_copyin_messages.cpp b/clang/test/OpenMP/parallel_master_copyin_messages.cpp
new file mode 100644
index 00000000000..8eda887864b
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_copyin_messages.cpp
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
+void foo() {
+}
+
+bool foobool(int argc) {
+ return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+class S2 {
+ mutable int a;
+
+public:
+ S2() : a(0) {}
+ S2 &operator=(S2 &s2) { return *this; }
+};
+class S3 {
+ int a;
+
+public:
+ S3() : a(0) {}
+ S3 &operator=(S3 &s3) { return *this; }
+};
+class S4 {
+ int a;
+ S4();
+ S4 &operator=(const S4 &s4); // expected-note {{implicitly declared private here}}
+
+public:
+ S4(int v) : a(v) {}
+};
+class S5 {
+ int a;
+ S5() : a(0) {}
+ S5 &operator=(const S5 &s5) { return *this; } // expected-note {{implicitly declared private here}}
+
+public:
+ S5(int v) : a(v) {}
+};
+template <class T>
+class ST {
+public:
+ static T s;
+};
+
+S2 k;
+S3 h;
+S4 l(3);
+S5 m(4);
+#pragma omp threadprivate(h, k, l, m)
+
+namespace A {
+double x;
+#pragma omp threadprivate(x)
+}
+namespace B {
+using A::x;
+}
+
+int main(int argc, char **argv) {
+ int i;
+#pragma omp parallel master copyin // expected-error {{expected '(' after 'copyin'}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin() // expected-error {{expected expression}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin(k // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin(h, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin(l) // expected-error {{'operator=' is a private member of 'S4'}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin(S1) // expected-error {{'S1' does not refer to a value}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin(argv[1]) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin(i) // expected-error {{copyin variable must be threadprivate}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin(m) // expected-error {{'operator=' is a private member of 'S5'}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyin(ST < int > ::s, B::x) // expected-error {{copyin variable must be threadprivate}}
+ {
+ foo();
+ }
+
+ return 0;
+}
diff --git a/clang/test/OpenMP/parallel_master_default_messages.cpp b/clang/test/OpenMP/parallel_master_default_messages.cpp
new file mode 100644
index 00000000000..557cba5aa32
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_default_messages.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
+void foo();
+
+int main(int argc, char **argv) {
+#pragma omp parallel master default // expected-error {{expected '(' after 'default'}}
+ {
+#pragma omp parallel master default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+#pragma omp parallel master default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+ {
+#pragma omp parallel master default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+#pragma omp parallel master default(shared), default(shared) // expected-error {{directive '#pragma omp parallel master' cannot contain more than one 'default' clause}}
+ {
+#pragma omp parallel master default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+ {
+ foo();
+ }
+ }
+ }
+ }
+ }
+ }
+
+#pragma omp parallel master default(none) // expected-note {{explicit data sharing attribute requested here}}
+ {
+ ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+ }
+
+#pragma omp parallel master default(none) // expected-note {{explicit data sharing attribute requested here}}
+ {
+#pragma omp parallel master default(shared)
+ {
+ ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+ }
+ }
+ return 0;
+}
diff --git a/clang/test/OpenMP/parallel_master_firstprivate_messages.cpp b/clang/test/OpenMP/parallel_master_firstprivate_messages.cpp
new file mode 100644
index 00000000000..fb3158c8233
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_firstprivate_messages.cpp
@@ -0,0 +1,320 @@
+// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
+
+extern int omp_default_mem_alloc;
+void foo() {
+}
+
+bool foobool(int argc) {
+ return argc;
+}
+
+void xxx(int argc) {
+ int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp parallel master firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+ {
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+}
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{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;
+ S3 &operator=(const S3 &s3);
+
+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 2 {{implicitly declared private here}}
+
+public:
+ S4(int v) : a(v) {}
+};
+class S5 {
+ int a;
+ S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
+
+public:
+ S5() : a(0) {}
+ S5(int v) : a(v) {}
+};
+class S6 {
+ int a;
+ S6() : a(0) {}
+
+public:
+ S6(const S6 &s6) : a(s6.a) {}
+ S6(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class I, class C>
+int foomain(int argc, char **argv) {
+ I e(4);
+ C g(5);
+ int i, z;
+ int &j = i;
+#pragma omp parallel master firstprivate // expected-error {{expected '(' after 'firstprivate'}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate() // expected-error {{expected expression}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(z, a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(argv[1]) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
+ {
+ foo();
+ }
+#pragma omp parallel master linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel master'}}
+ {
+ foo();
+ }
+#pragma omp parallel
+ {
+ int v = 0;
+ int i;
+#pragma omp parallel master firstprivate(i)
+ {
+ foo();
+ }
+ v += i;
+ }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp parallel master firstprivate(j)
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(i)
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
+ {
+ foo();
+ }
+#pragma omp parallel private(i)
+#pragma omp parallel master firstprivate(i)
+ {
+ foo();
+ }
+#pragma omp parallel reduction(+ : i)
+#pragma omp parallel master firstprivate(i)
+ {
+ foo();
+ }
+ return 0;
+}
+
+namespace A {
+double x;
+#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
+}
+namespace B {
+using A::x;
+}
+
+int main(int argc, char **argv) {
+ const int d = 5;
+ const int da[5] = {0};
+ S4 e(4);
+ S5 g(5);
+ S3 m;
+ S6 n(2);
+ int i, z;
+ int &j = i;
+#pragma omp parallel master firstprivate // expected-error {{expected '(' after 'firstprivate'}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate() // expected-error {{expected expression}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(argc, z)
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(argv[1]) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(2 * 2) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(ba) // OK
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(ca) // OK
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(da) // OK
+ {
+ foo();
+ }
+ int xa;
+#pragma omp parallel master firstprivate(xa) // OK
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(S2::S2s) // OK
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(S2::S2sc) // OK
+ {
+ foo();
+ }
+#pragma omp parallel master safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel master'}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(m) // OK
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
+ {
+ foo();
+ }
+#pragma omp parallel shared(xa)
+#pragma omp parallel master firstprivate(xa) // OK: may be firstprivate
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(j)
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
+ {
+ foo();
+ }
+#pragma omp parallel master firstprivate(n) // OK
+ {
+ foo();
+ }
+#pragma omp parallel
+ {
+ int v = 0;
+ int i;
+#pragma omp parallel master firstprivate(i)
+ {
+ foo();
+ }
+ v += i;
+ }
+#pragma omp parallel private(i)
+#pragma omp parallel master firstprivate(i)
+ {
+ foo();
+ }
+#pragma omp parallel reduction(+ : i)
+#pragma omp parallel master firstprivate(i)
+ {
+ foo();
+ }
+ static int r;
+#pragma omp parallel master firstprivate(r) // OK
+ {
+ foo();
+ }
+
+ return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
+}
diff --git a/clang/test/OpenMP/parallel_master_if_messages.cpp b/clang/test/OpenMP/parallel_master_if_messages.cpp
new file mode 100644
index 00000000000..dd156869481
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_if_messages.cpp
@@ -0,0 +1,173 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
+
+void foo() {
+}
+
+bool foobool(int argc) {
+ return argc;
+}
+
+void xxx(int argc) {
+ int cond; // expected-note {{initialize the variable 'cond' to silence this warning}}
+#pragma omp parallel master if(cond) // expected-warning {{variable 'cond' is uninitialized when used here}}
+ {
+ ;
+ }
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, class S> // expected-note {{declared here}}
+int tmain(T argc, S **argv) {
+ T z;
+ #pragma omp parallel master if // expected-error {{expected '(' after 'if'}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if () // expected-error {{expected expression}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (argc > 0 ? argv[1] : argv[2])
+ {
+ foo();
+ }
+ #pragma omp parallel master if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp parallel master' cannot contain more than one 'if' clause}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (S) // expected-error {{'S' does not refer to a value}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(argc + z)
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : argc)
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp parallel master'}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp parallel master' cannot contain more than one 'if' clause with 'parallel' name modifier}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
+ {
+ foo();
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ int z;
+ #pragma omp parallel master if // expected-error {{expected '(' after 'if'}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if () // expected-error {{expected expression}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (argc > 0 ? argv[1] : argv[2] + z)
+ {
+ foo();
+ }
+ #pragma omp parallel master if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp parallel master' cannot contain more than one 'if' clause}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (S1) // expected-error {{'S1' does not refer to a value}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : argc)
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp parallel master'}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp parallel master' cannot contain more than one 'if' clause with 'parallel' name modifier}}
+ {
+ foo();
+ }
+ #pragma omp parallel master if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
+ {
+ foo();
+ }
+
+ return tmain(argc, argv);
+}
diff --git a/clang/test/OpenMP/parallel_master_message.cpp b/clang/test/OpenMP/parallel_master_message.cpp
new file mode 100644
index 00000000000..4b89755ac28
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_message.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
+
+void xxx(int argc) {
+ int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp parallel master
+ argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
+#pragma omp parallel master // expected-error {{unexpected OpenMP directive '#pragma omp parallel master'}}
+
+int foo() {
+ return 0;
+}
+
+int a;
+struct S;
+S& bar();
+int main(int argc, char **argv) {
+ #pragma omp parallel master nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel master'}}
+ #pragma omp parallel master unknown // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ foo();
+ {
+ #pragma omp master
+ } // expected-error {{expected statement}}
+ {
+ #pragma omp parallel master
+ } // expected-error {{expected statement}}
+
+ S &s = bar();
+ #pragma omp parallel master
+ (void)&s;
+ #pragma omp parallel master { // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ foo();
+ #pragma omp parallel master ( // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ foo();
+ #pragma omp parallel master [ // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ foo();
+ #pragma omp parallel master ] // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ foo();
+ #pragma omp parallel master ) // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ foo();
+ #pragma omp parallel master } // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ foo();
+ #pragma omp parallel master
+ // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ #pragma omp parallel master unknown()
+ foo();
+ L1:
+ foo();
+ #pragma omp parallel master
+ ;
+ #pragma omp parallel master
+ {
+
+ for (int i = 0; i < 10; ++i) {
+ switch(argc) {
+ case (0):
+ #pragma omp parallel master
+ {
+ foo();
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ }
+ default:
+ break;
+ }
+ }
+ goto L1; // expected-error {{use of undeclared label 'L1'}}
+ argc++;
+ }
+#pragma omp parallel master default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
+ {
+ ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+ ++a; // expected-error {{variable 'a' must have explicitly specified data sharing attributes}}
+ }
+
+ goto L2; // expected-error {{use of undeclared label 'L2'}}
+ #pragma omp parallel master
+ L2:
+ foo();
+ #pragma omp parallel master
+ {
+ return 1; // expected-error {{cannot return from OpenMP region}}
+ }
+ return 0;
+}
diff --git a/clang/test/OpenMP/parallel_master_num_threads_messages.cpp b/clang/test/OpenMP/parallel_master_num_threads_messages.cpp
new file mode 100644
index 00000000000..601164f1e53
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_num_threads_messages.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+
+void foo() {
+}
+
+bool foobool(int argc) {
+ return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, typename S, int N> // expected-note {{declared here}}
+T tmain(T argc, S **argv) {
+ T z;
+ #pragma omp parallel master num_threads // expected-error {{expected '(' after 'num_threads'}}
+ {foo();}
+ #pragma omp parallel master num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {foo();}
+ #pragma omp parallel master num_threads () // expected-error {{expected expression}}
+ {foo();}
+ #pragma omp parallel master num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {foo();}
+ #pragma omp parallel master num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ {foo();}
+ #pragma omp parallel master num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
+ {foo();}
+ #pragma omp parallel master num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel master' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
+ {foo();}
+ #pragma omp parallel master num_threads (S) // expected-error {{'S' does not refer to a value}}
+ {foo();}
+ #pragma omp parallel master num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
+ {foo();}
+ #pragma omp parallel master num_threads (argc + z)
+ {foo();}
+ #pragma omp parallel master num_threads (N) // expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
+ {foo();}
+
+ return argc;
+}
+
+int main(int argc, char **argv) {
+ int z;
+ #pragma omp parallel master num_threads // expected-error {{expected '(' after 'num_threads'}}
+ {foo();}
+ #pragma omp parallel master num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {foo();}
+ #pragma omp parallel master num_threads () // expected-error {{expected expression}}
+ {foo();}
+ #pragma omp parallel master num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {foo();}
+ #pragma omp parallel master num_threads (argc / z)) // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ {foo();}
+ #pragma omp parallel master num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }}
+ {foo();}
+ #pragma omp parallel master num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel master' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
+ {foo();}
+ #pragma omp parallel master num_threads (S1) // expected-error {{'S1' does not refer to a value}}
+ {foo();}
+ #pragma omp parallel master num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}}
+ {foo();}
+ #pragma omp parallel master num_threads (num_threads(tmain<int, char, -1>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain<int, char, -1>' requested here}}
+ {foo();}
+
+ return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}
+}
diff --git a/clang/test/OpenMP/parallel_master_private_messages.cpp b/clang/test/OpenMP/parallel_master_private_messages.cpp
new file mode 100644
index 00000000000..2e21a1acd3f
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_private_messages.cpp
@@ -0,0 +1,284 @@
+// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
+
+extern int omp_default_mem_alloc;
+void foo() {
+}
+
+bool foobool(int argc) {
+ return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+ mutable int a;
+
+public:
+ S2() : a(0) {}
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+ int a;
+
+public:
+ S3() : a(0) {}
+};
+const S3 ca[5];
+class S4 {
+ int a;
+ S4(); // expected-note {{implicitly declared private here}}
+
+public:
+ S4(int v) : a(v) {
+#pragma omp parallel master private(a) private(this->a)
+ {
+ for (int k = 0; k < v; ++k)
+ ++this->a;
+ }
+ }
+};
+class S5 {
+ int a;
+ S5() : a(0) {} // expected-note {{implicitly declared private here}}
+
+public:
+ S5(int v) : a(v) {}
+ S5 &operator=(S5 &s) {
+#pragma omp parallel master private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
+ {
+ for (int k = 0; k < s.a; ++k)
+ ++s.a;
+ }
+ return *this;
+ }
+};
+
+template <typename T>
+class S6 {
+public:
+ T a;
+
+ S6() : a(0) {}
+ S6(T v) : a(v) {
+#pragma omp parallel master private(a) private(this->a)
+ {
+ for (int k = 0; k < v; ++k)
+ ++this->a;
+ }
+ }
+ S6 &operator=(S6 &s) {
+#pragma omp parallel master private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
+ {
+ for (int k = 0; k < s.a; ++k)
+ ++s.a;
+ }
+ return *this;
+ }
+};
+
+template <typename T>
+class S7 : public T {
+ T a;
+ S7() : a(0) {}
+
+public:
+ S7(T v) : a(v) {
+#pragma omp parallel master private(a) private(this->a) private(T::a)
+ {
+ for (int k = 0; k < a.a; ++k)
+ ++this->a.a;
+ }
+ }
+ S7 &operator=(S7 &s) {
+#pragma omp parallel master private(a) private(this->a) private(s.a) private(s.T::a) // expected-error 2 {{expected variable name or data member of current class}}
+ {
+ for (int k = 0; k < s.a.a; ++k)
+ ++s.a.a;
+ }
+ return *this;
+ }
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class I, class C>
+int foomain(I argc, C **argv) {
+ I e(4);
+ I g(5);
+ int i, z;
+ int &j = i;
+#pragma omp parallel master private // expected-error {{expected '(' after 'private'}}
+ {
+ foo();
+ }
+#pragma omp parallel master private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master private() // expected-error {{expected expression}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(S1) // expected-error {{'S1' does not refer to a value}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(argv[1]) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(e, g, z)
+ {
+ foo();
+ }
+#pragma omp parallel master private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyprivate(h) // expected-error {{unexpected OpenMP clause 'copyprivate' in directive '#pragma omp parallel master'}}
+ {
+ foo();
+ }
+#pragma omp parallel
+ {
+ int v = 0;
+ int i;
+#pragma omp parallel master private(i)
+ {
+ foo();
+ }
+ v += i;
+ }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp parallel master private(j)
+ {
+ foo();
+ }
+#pragma omp parallel master private(i)
+ {
+ foo();
+ }
+ return 0;
+}
+
+namespace A {
+double x;
+#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
+}
+namespace B {
+using A::x;
+}
+
+int main(int argc, char **argv) {
+ S4 e(4);
+ S5 g(5);
+ S6<float> s6(0.0) , s6_0(1.0);
+ S7<S6<float> > s7(0.0) , s7_0(1.0);
+ int i, z;
+ int &j = i;
+#pragma omp parallel master private // expected-error {{expected '(' after 'private'}}
+ {
+ foo();
+ }
+#pragma omp parallel master private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master private() // expected-error {{expected expression}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(argc, z)
+ {
+ foo();
+ }
+#pragma omp parallel master private(S1) // expected-error {{'S1' does not refer to a value}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(argv[1]) // expected-error {{expected variable name}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+ {
+ foo();
+ }
+#pragma omp parallel master private(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}}
+ {
+ foo();
+ }
+#pragma omp parallel master copyprivate(h) // expected-error {{unexpected OpenMP clause 'copyprivate' in directive '#pragma omp parallel master'}}
+ {
+ foo();
+ }
+#pragma omp parallel
+ {
+ int i;
+#pragma omp parallel master private(i)
+ {
+ foo();
+ }
+ }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp parallel master private(j)
+ {
+ foo();
+ }
+#pragma omp parallel master private(i)
+ {
+ foo();
+ }
+ static int m;
+#pragma omp parallel master private(m)
+ {
+ foo();
+ }
+
+ s6 = s6_0; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}}
+ s7 = s7_0; // expected-note {{in instantiation of member function 'S7<S6<float> >::operator=' requested here}}
+ return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
+}
+
diff --git a/clang/test/OpenMP/parallel_master_proc_bind_messages.cpp b/clang/test/OpenMP/parallel_master_proc_bind_messages.cpp
new file mode 100644
index 00000000000..dd3220c0cb8
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_proc_bind_messages.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
+void foo();
+
+int main(int argc, char **argv) {
+#pragma omp parallel master proc_bind // expected-error {{expected '(' after 'proc_bind'}}
+ { foo(); }
+#pragma omp parallel master proc_bind( // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ { foo(); }
+#pragma omp parallel master proc_bind() // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}}
+ { foo(); }
+#pragma omp parallel master proc_bind(master // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ { foo(); }
+#pragma omp parallel master proc_bind(close), proc_bind(spread) // expected-error {{directive '#pragma omp parallel master' cannot contain more than one 'proc_bind' clause}}
+ { foo(); }
+#pragma omp parallel master proc_bind(x) // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}}
+ { foo(); }
+
+#pragma omp parallel master proc_bind(master)
+ { ++argc; }
+
+#pragma omp parallel master proc_bind(close)
+ {
+#pragma omp parallel master proc_bind(spread)
+ { ++argc; }
+ }
+ return 0;
+}
diff --git a/clang/test/OpenMP/parallel_master_reduction_messages.cpp b/clang/test/OpenMP/parallel_master_reduction_messages.cpp
new file mode 100644
index 00000000000..4a5f8d2cb9f
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_reduction_messages.cpp
@@ -0,0 +1,398 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 -ferror-limit 150 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 150 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 -ferror-limit 150 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -ferror-limit 150 -o - %s -Wuninitialized
+
+extern int omp_default_mem_alloc;
+void xxx(int argc) {
+ int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp parallel master reduction(+:fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+{
+ for (int i = 0; i < 10; ++i)
+ ;
+}
+}
+
+void foo() {
+}
+
+bool foobool(int argc) {
+ return argc;
+}
+
+void foobar(int &ref) {
+#pragma omp parallel master reduction(+:ref)
+ {
+ foo();
+ }
+}
+
+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); } // expected-note 3 {{implicitly declared private here}}
+
+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; // expected-note 2 {{'S2sc' declared here}}
+};
+const float S2::S2sc = 0;
+S2 b; // expected-note 3 {{'b' defined here}}
+const S2 ba[5]; // expected-note 2 {{'ba' defined here}}
+class S3 {
+ int a;
+
+public:
+ int b;
+ 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 3 {{'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 {
+ int a;
+ S4(); // expected-note {{implicitly declared private here}}
+ 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) {} // expected-note {{implicitly declared private here}}
+ S5(const S5 &s5) : a(s5.a) {}
+ S5 &operator+(const S5 &arg);
+
+public:
+ S5(int v) : a(v) {}
+};
+class S6 { // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'const S6' for 1st argument}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
+#endif
+ int a;
+
+public:
+ S6() : a(6) {}
+ operator int() { return 6; }
+} o;
+
+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) {
+ 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, z;
+ 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;
+#pragma omp parallel master reduction // expected-error {{expected '(' after 'reduction'}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(&& : argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(^ : T) // expected-error {{'T' does not refer to a value}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : z, a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 3 {{const-qualified variable cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 4 {{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 parallel master reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : ba) // expected-error {{const-qualified variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(* : ca) // expected-error {{const-qualified variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(- : da) // expected-error {{const-qualified variable cannot be reduction}} expected-error {{const-qualified variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
+ {
+ foo();
+ }
+#pragma omp parallel master 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 parallel master reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}
+ {
+ foo();
+ }
+#pragma omp parallel master 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 parallel master reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+ {
+ foo();
+ }
+#pragma omp parallel private(fl)
+#pragma omp parallel master reduction(+ : fl)
+ {
+ foo();
+ }
+#pragma omp parallel reduction(* : fl)
+#pragma omp parallel master reduction(+ : fl)
+ {
+ foo();
+ }
+
+ return T();
+}
+
+namespace A {
+double x;
+#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
+}
+namespace B {
+using A::x;
+}
+
+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);
+ S5 g(5);
+ int i, z;
+ 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;
+#pragma omp parallel master reduction // expected-error {{expected '(' after 'reduction'}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+ {
+ foo();
+ }
+#pragma omp parallel master 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 parallel master reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(~ : argc) // expected-error {{expected unqualified-id}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(&& : argc)
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{const-qualified variable cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(min : a, b, c, d, f) // expected-error {{a reduction list item 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 parallel master reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : ba) // expected-error {{const-qualified variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(* : ca) // expected-error {{const-qualified variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(- : da) // expected-error {{const-qualified variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{invalid operands to binary expression ('S4' and 'S4')}} expected-error {{calling a private constructor of class 'S5'}} expected-error {{invalid operands to binary expression ('S5' and 'S5')}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : o, z) // expected-error {{no viable overloaded '='}}
+ {
+ foo();
+ }
+#pragma omp parallel master 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 parallel master reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
+ {
+ foo();
+ }
+#pragma omp parallel master reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}
+ {
+ foo();
+ }
+#pragma omp parallel shared(i)
+#pragma omp parallel reduction(min : i)
+#pragma omp parallel master reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+ {
+ foo();
+ }
+#pragma omp parallel private(fl)
+#pragma omp parallel master reduction(+ : fl)
+ {
+ foo();
+ }
+#pragma omp parallel reduction(* : fl)
+#pragma omp parallel master reduction(+ : fl)
+ {
+ foo();
+ }
+ static int m;
+#pragma omp parallel master reduction(+ : m) // OK
+ {
+ 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/parallel_master_shared_messages.cpp b/clang/test/OpenMP/parallel_master_shared_messages.cpp
new file mode 100644
index 00000000000..1bda6c393a9
--- /dev/null
+++ b/clang/test/OpenMP/parallel_master_shared_messages.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+
+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}}
+
+namespace A {
+double x;
+#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
+}
+namespace B {
+using A::x;
+}
+
+int main(int argc, char **argv) {
+ const int d = 5;
+ const int da[5] = {0};
+ S4 e(4);
+ S5 g(5);
+ int i, k;
+ int &j = i;
+#pragma omp parallel master shared // expected-error {{expected '(' after 'shared'}}
+ { foo(); }
+#pragma omp parallel master shared( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ { foo(); }
+#pragma omp parallel master shared() // expected-error {{expected expression}}
+ { foo(); }
+#pragma omp parallel master shared(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ { foo(); }
+#pragma omp parallel master shared(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ { foo(); }
+#pragma omp parallel master shared(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+ { foo(); }
+#pragma omp parallel master shared(argc)
+ { foo(); }
+#pragma omp parallel master shared(S1) // expected-error {{'S1' does not refer to a value}}
+ { foo(); }
+#pragma omp parallel master shared(a, b, c, d, f, k)
+ { foo(); }
+#pragma omp parallel master shared(argv[1]) // expected-error {{expected variable name}}
+ { foo(); }
+#pragma omp parallel master shared(ba)
+ { foo(); }
+#pragma omp parallel master shared(ca)
+ { foo(); }
+#pragma omp parallel master shared(da)
+ { foo(); }
+#pragma omp parallel master shared(e, g)
+ { foo(); }
+#pragma omp parallel master shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
+ { foo(); }
+#pragma omp parallel master private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
+ { foo(); }
+#pragma omp parallel master firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
+ { foo(); }
+#pragma omp parallel master private(i)
+ {
+#pragma omp parallel master shared(i)
+ {
+#pragma omp parallel master shared(j)
+ { foo(); }
+ }
+ }
+#pragma omp parallel master firstprivate(i)
+ {
+#pragma omp parallel master shared(i)
+ {
+#pragma omp parallel master shared(j)
+ { foo(); }
+ }
+ }
+
+ return 0;
+}
OpenPOWER on IntegriCloud