summaryrefslogtreecommitdiff
path: root/test/OpenMP/task_messages.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-10-08 10:42:55 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-10-08 10:42:55 +0000
commit10b0957de4fe18602a2c45f3bb8afa1c4fae65be (patch)
treeed7c2ad862766159ff6ca65410d895833975fc5b /test/OpenMP/task_messages.cpp
parent37d95eb570d368aee65a2886788ac8ab9dd1b8ee (diff)
downloadclang-10b0957de4fe18602a2c45f3bb8afa1c4fae65be.tar.gz
[OPENMP] Codegen for 'firstprivate' clause.
This patch generates some helper variables that used as private copies of the corresponding original variables inside an OpenMP 'parallel' directive. These generated variables are initialized by copy using values of the original variables (with the copy constructor, if any). For arrays, initializator is generated for single element and in the codegen procedure this initial value is automatically propagated between all elements of the private copy. In outlined function, references to original variables are replaced by the references to these private helper variables. At the end of the initialization of the private variables an implicit barier is generated by calling __kmpc_barrier(...) runtime function to be sure that all threads were initialized using original values of the variables. Differential Revision: http://reviews.llvm.org/D5140 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219295 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/OpenMP/task_messages.cpp')
-rw-r--r--test/OpenMP/task_messages.cpp48
1 files changed, 29 insertions, 19 deletions
diff --git a/test/OpenMP/task_messages.cpp b/test/OpenMP/task_messages.cpp
index 88c339afc1..b02b43c2b3 100644
--- a/test/OpenMP/task_messages.cpp
+++ b/test/OpenMP/task_messages.cpp
@@ -5,8 +5,8 @@ void foo() {
#pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}}
-class S { // expected-note 6 {{'S' declared here}}
- S(const S &s) { a = s.a + 12; }
+class S {
+ S(const S &s) { a = s.a + 12; } // expected-note 6 {{implicitly declared private here}}
int a;
public:
@@ -17,23 +17,35 @@ public:
S operator+(const S &) { return *this; }
};
+class S1 {
+ int a;
+
+public:
+ S1() : a(0) {}
+ S1 &operator++() { return *this; }
+ S1(const S1 &) = delete; // expected-note 2 {{'S1' has been explicitly marked deleted here}}
+};
+
template <class T>
int foo() {
- T a; // expected-note 3 {{'a' defined here}}
+ T a;
T &b = a; // expected-note 4 {{'b' defined here}}
int r;
+ S1 s1;
+// expected-error@+1 2 {{call to deleted constructor of 'S1'}}
+#pragma omp task
+// expected-note@+1 2 {{predetermined as a firstprivate in a task construct here}}
+ ++s1;
#pragma omp task default(none)
#pragma omp task default(shared)
++a;
-// expected-error@+2 {{predetermined as a firstprivate in a task construct variable must have an accessible, unambiguous copy constructor}}
#pragma omp task default(none)
#pragma omp task
-// expected-note@+1 {{used here}}
+ // expected-error@+1 {{calling a private constructor of class 'S'}}
++a;
#pragma omp task
-// expected-error@+1 {{predetermined as a firstprivate in a task construct variable must have an accessible, unambiguous copy constructor}}
#pragma omp task
- // expected-note@+1 {{used here}}
+ // expected-error@+1 {{calling a private constructor of class 'S'}}
++a;
#pragma omp task default(shared)
#pragma omp task
@@ -46,11 +58,11 @@ int foo() {
#pragma omp task
// expected-note@+1 2 {{used here}}
++b;
-// expected-error@+3 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'int &'}}
-// expected-error@+2 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'S &'}}
-// expected-error@+1 {{predetermined as a firstprivate in a task construct variable must have an accessible, unambiguous copy constructor}}
+// expected-error@+2 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'int &'}}
+// expected-error@+1 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'S &'}}
#pragma omp task
-// expected-note@+1 3 {{used here}}
+// expected-error@+2 {{calling a private constructor of class 'S'}}
+// expected-note@+1 2 {{used here}}
#pragma omp parallel shared(a, b)
++a, ++b;
// expected-note@+1 3 {{defined as reduction}}
@@ -109,7 +121,7 @@ int foo() {
int main(int argc, char **argv) {
int a;
int &b = a; // expected-note 2 {{'b' defined here}}
- S sa; // expected-note 3 {{'sa' defined here}}
+ S sa;
S &sb = sa; // expected-note 2 {{'sb' defined here}}
int r;
#pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
@@ -193,14 +205,12 @@ L2:
#pragma omp task default(shared)
++sa;
#pragma omp task default(none)
-// expected-error@+1 {{predetermined as a firstprivate in a task construct variable must have an accessible, unambiguous copy constructor}}
#pragma omp task
-// expected-note@+1 {{used here}}
+ // expected-error@+1 {{calling a private constructor of class 'S'}}
++sa;
#pragma omp task
-// expected-error@+1 {{predetermined as a firstprivate in a task construct variable must have an accessible, unambiguous copy constructor}}
#pragma omp task
-// expected-note@+1 {{used here}}
+ // expected-error@+1 {{calling a private constructor of class 'S'}}
++sa;
#pragma omp task default(shared)
#pragma omp task
@@ -212,10 +222,10 @@ L2:
#pragma omp task
// expected-note@+1 {{used here}}
++sb;
-// expected-error@+2 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'S &'}}
-// expected-error@+1 {{predetermined as a firstprivate in a task construct variable must have an accessible, unambiguous copy constructor}}
+// expected-error@+1 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'S &'}}
#pragma omp task
-// expected-note@+1 2 {{used here}}
+// expected-error@+2 {{calling a private constructor of class 'S'}}
+// expected-note@+1 {{used here}}
#pragma omp parallel shared(sa, sb)
++sa, ++sb;
// expected-note@+1 2 {{defined as reduction}}