aboutsummaryrefslogtreecommitdiff
path: root/test/OpenMP/simd_loop_messages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/OpenMP/simd_loop_messages.cpp')
-rw-r--r--test/OpenMP/simd_loop_messages.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/OpenMP/simd_loop_messages.cpp b/test/OpenMP/simd_loop_messages.cpp
index ea663fddd9cf..ce64842d68a9 100644
--- a/test/OpenMP/simd_loop_messages.cpp
+++ b/test/OpenMP/simd_loop_messages.cpp
@@ -2,6 +2,7 @@
static int sii;
#pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+static int globalii;
int test_iteration_spaces() {
const int N = 100;
@@ -257,6 +258,23 @@ int test_iteration_spaces() {
c[sii] = a[sii];
}
+ #pragma omp parallel
+ {
+ // expected-error@+2 {{loop iteration variable in the associated loop of 'omp simd' directive may not be a variable with global storage without being explicitly marked as linear}}
+ #pragma omp simd
+ for (globalii = 0; globalii < 10; globalii+=1)
+ c[globalii] = a[globalii];
+ }
+
+ #pragma omp parallel
+ {
+// expected-error@+3 {{loop iteration variable in the associated loop of 'omp simd' directive may not be a variable with global storage without being explicitly marked as lastprivate}}
+#pragma omp simd collapse(2)
+ for (ii = 0; ii < 10; ii += 1)
+ for (globalii = 0; globalii < 10; globalii += 1)
+ c[globalii] += a[globalii] + ii;
+ }
+
// expected-error@+2 {{statement after '#pragma omp simd' must be a for loop}}
#pragma omp simd
for (auto &item : a) {
@@ -300,8 +318,10 @@ class Iter0 {
Iter0(const Iter0 &) { }
Iter0 operator ++() { return *this; }
Iter0 operator --() { return *this; }
+ Iter0 operator + (int delta) { return *this; }
bool operator <(Iter0 a) { return true; }
};
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
int operator -(Iter0 a, Iter0 b) { return 0; }
class Iter1 {
public:
@@ -330,10 +350,14 @@ class GoodIter {
typedef int difference_type;
typedef std::random_access_iterator_tag iterator_category;
};
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
int operator -(GoodIter a, GoodIter b) { return 0; }
+// expected-note@+1 2 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
GoodIter operator -(GoodIter a) { return a; }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
GoodIter operator -(GoodIter a, int v) { return GoodIter(); }
GoodIter operator +(GoodIter a, int v) { return GoodIter(); }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
GoodIter operator -(int v, GoodIter a) { return GoodIter(); }
GoodIter operator +(int v, GoodIter a) { return GoodIter(); }
@@ -370,7 +394,7 @@ int test_with_random_access_iterator() {
for (begin = GoodIter(0); begin < end; ++begin)
++begin;
#pragma omp simd
- for (begin = begin0; begin < end; ++begin)
+ for (begin = GoodIter(1,2); begin < end; ++begin)
++begin;
// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
#pragma omp simd
@@ -415,12 +439,16 @@ int test_with_random_access_iterator() {
#pragma omp simd
for (Iter0 I = begin0; I < end0; ++I)
++I;
+
// Initializer is constructor without params.
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp simd
for (Iter0 I; I < end0; ++I)
++I;
+
Iter1 begin1, end1;
+ // expected-error@+3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+ // expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
#pragma omp simd
for (Iter1 I = begin1; I < end1; ++I)
++I;
@@ -429,11 +457,15 @@ int test_with_random_access_iterator() {
#pragma omp simd
for (Iter1 I = begin1; I >= end1; ++I)
++I;
+
// Initializer is constructor with all default params.
+ // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+ // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
#pragma omp simd
for (Iter1 I; I < end1; ++I) {
}
+
return 0;
}