summaryrefslogtreecommitdiffstats
path: root/test/OpenMP/atomic_messages.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-07-23 10:25:33 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-07-23 10:25:33 +0000
commitd380fa48567ffe1676f058256f2418414f17d32f (patch)
treeb394314983fe53ad7385a89286eedfef2cb759f7 /test/OpenMP/atomic_messages.cpp
parent08c4b31800a9edacc32c5c84a4c44cd8a9fdd23b (diff)
[OPENMP] Initial parsing and sema analysis for 'update' clause of 'atomic' directive.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213735 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/OpenMP/atomic_messages.cpp')
-rw-r--r--test/OpenMP/atomic_messages.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/OpenMP/atomic_messages.cpp b/test/OpenMP/atomic_messages.cpp
index 4bc7686c11..d7856cc229 100644
--- a/test/OpenMP/atomic_messages.cpp
+++ b/test/OpenMP/atomic_messages.cpp
@@ -4,12 +4,14 @@ int foo() {
L1:
foo();
#pragma omp atomic
+// expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
{
foo();
goto L1; // expected-error {{use of undeclared label 'L1'}}
}
goto L2; // expected-error {{use of undeclared label 'L2'}}
#pragma omp atomic
+// expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
{
foo();
L2:
@@ -74,6 +76,41 @@ int write() {
}
template <class T>
+T update() {
+ T a, b = 0;
+// Test for atomic update
+#pragma omp atomic update
+// expected-error@+1 {{the statement for 'atomic update' 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-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}}
+#pragma omp atomic update update
+ a += b;
+
+#pragma omp atomic
+// expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+ ;
+
+ return T();
+}
+
+int update() {
+ int a, b = 0;
+// Test for atomic update
+#pragma omp atomic update
+// expected-error@+1 {{the statement for 'atomic update' 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-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}}
+#pragma omp atomic update update
+ a += b;
+
+#pragma omp atomic
+// expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+ ;
+
+ return update<int>();
+}
+
+template <class T>
T mixed() {
T a, b = T();
// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
@@ -84,6 +121,10 @@ T mixed() {
// expected-note@+1 2 {{'write' clause used here}}
#pragma omp atomic write read
a = b;
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note@+1 2 {{'update' clause used here}}
+#pragma omp atomic update read
+ a += b;
return T();
}
@@ -97,6 +138,10 @@ int mixed() {
// expected-note@+1 {{'write' clause used here}}
#pragma omp atomic write read
a = b;
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note@+1 {{'write' clause used here}}
+#pragma omp atomic write update
+ a = b;
// expected-note@+1 {{in instantiation of function template specialization 'mixed<int>' requested here}}
return mixed<int>();
}