r275306 - [OpenMP] add more tests for 'distribute simd' pragma
Kelvin Li via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 13 12:16:57 PDT 2016
Author: kli
Date: Wed Jul 13 14:16:56 2016
New Revision: 275306
URL: http://llvm.org/viewvc/llvm-project?rev=275306&view=rev
Log:
[OpenMP] add more tests for 'distribute simd' pragma
This patch is to add two additional tests for testing 'distribute simd' pragma with disallowed clauses and loops.
Differential Revision: http://reviews.llvm.org/D22176
Added:
cfe/trunk/test/OpenMP/distribute_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c
Added: cfe/trunk/test/OpenMP/distribute_simd_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_loop_messages.cpp?rev=275306&view=auto
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_simd_loop_messages.cpp (added)
+++ cfe/trunk/test/OpenMP/distribute_simd_loop_messages.cpp Wed Jul 13 14:16:56 2016
@@ -0,0 +1,782 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s
+
+static int sii;
+// expected-note at +1 {{defined as threadprivate or thread local}}
+#pragma omp threadprivate(sii)
+static int globalii;
+
+int test_iteration_spaces() {
+ const int N = 100;
+ float a[N], b[N], c[N];
+ int ii, jj, kk;
+ float fii;
+ double dii;
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (int i = 0; i < 10; i+=1) {
+ c[i] = a[i] + b[i];
+ }
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (char i = 0; i < 10; i++) {
+ c[i] = a[i] + b[i];
+ }
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (char i = 0; i < 10; i+='\1') {
+ c[i] = a[i] + b[i];
+ }
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (long long i = 0; i < 10; i++) {
+ c[i] = a[i] + b[i];
+ }
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{expression must have integral or unscoped enumeration type, not 'double'}}
+ #pragma omp distribute simd
+ for (long long i = 0; i < 10; i+=1.5) {
+ c[i] = a[i] + b[i];
+ }
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (long long i = 0; i < 'z'; i+=1u) {
+ c[i] = a[i] + b[i];
+ }
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{variable must be of integer or random access iterator type}}
+ #pragma omp distribute simd
+ for (float fi = 0; fi < 10.0; fi++) {
+ c[(int)fi] = a[(int)fi] + b[(int)fi];
+ }
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{variable must be of integer or random access iterator type}}
+ #pragma omp distribute simd
+ for (double fi = 0; fi < 10.0; fi++) {
+ c[(int)fi] = a[(int)fi] + b[(int)fi];
+ }
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (int &ref = ii; ref < 10; ref++) {
+ }
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (int i; i < 10; i++)
+ c[i] = a[i];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (int i = 0, j = 0; i < 10; ++i)
+ c[i] = a[i];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (;ii < 10; ++ii)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-warning at +3 {{expression result unused}}
+ // expected-error at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (ii + 1;ii < 10; ++ii)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (c[ii] = 0;ii < 10; ++ii)
+ c[ii] = a[ii];
+
+ // Ok to skip parenthesises.
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (((ii)) = 0;ii < 10; ++ii)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+ #pragma omp distribute simd
+ for (int i = 0; i; i++)
+ c[i] = a[i];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
+ #pragma omp distribute simd
+ for (int i = 0; jj < kk; ii++)
+ c[i] = a[i];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+ #pragma omp distribute simd
+ for (int i = 0; !!i; i++)
+ c[i] = a[i];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+ #pragma omp distribute simd
+ for (int i = 0; i != 1; i++)
+ c[i] = a[i];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+ #pragma omp distribute simd
+ for (int i = 0; ; i++)
+ c[i] = a[i];
+
+ // Ok.
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (int i = 11; i > 10; i--)
+ c[i] = a[i];
+
+ // Ok.
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (int i = 0; i < 10; ++i)
+ c[i] = a[i];
+
+ // Ok.
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; ++ii)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; ++jj)
+ c[ii] = a[jj];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; ++ ++ ii)
+ c[ii] = a[ii];
+
+ // Ok but undefined behavior (in general, cannot check that incr
+ // is really loop-invariant).
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; ii = ii + ii)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{expression must have integral or unscoped enumeration type, not 'float'}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; ii = ii + 1.0f)
+ c[ii] = a[ii];
+
+ // Ok - step was converted to integer type.
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; ii = ii + (int)1.1f)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; jj = ii + 2)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-warning at +3 {{relational comparison result unused}}
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; jj > kk + 2)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10;)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-warning at +3 {{expression result unused}}
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; !ii)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; ii ? ++ii : ++jj)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; ii = ii < 10)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be positive due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; ii = ii + 0)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be positive due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; ii = ii + (int)(0.8 - 0.45))
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be positive due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (ii = 0; (ii) < 10; ii-=25)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be positive due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (ii = 0; (ii < 10); ii-=0)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be negative due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (ii = 0; ii > 10; (ii+=0))
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be positive due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (ii = 0; ii < 10; (ii) = (1-1)+(ii))
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be negative due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for ((ii = 0); ii > 10; (ii-=0))
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be positive due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (ii = 0; (ii < 10); (ii-=0))
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +2 {{defined as private}}
+ // expected-error at +2 {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be private, predetermined as linear}}
+ #pragma omp distribute simd private(ii)
+ for (ii = 0; ii < 10; ii++)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +3 {{unexpected OpenMP clause 'shared' in directive '#pragma omp distribute simd'}}
+ // expected-note at +2 {{defined as shared}}
+ // expected-error at +2 {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be shared, predetermined as linear}}
+ #pragma omp distribute simd shared(ii)
+ for (ii = 0; ii < 10; ii++)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd linear(ii)
+ for (ii = 0; ii < 10; ii++)
+ c[ii] = a[ii];
+
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd lastprivate(ii) linear(jj) collapse(2) // expected-note {{defined as linear}}
+ for (ii = 0; ii < 10; ii++)
+ for (jj = 0; jj < 10; jj++) // expected-error {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be linear, predetermined as lastprivate}}
+ c[ii] = a[jj];
+
+
+ #pragma omp parallel
+ {
+ #pragma omp target
+ #pragma omp teams
+// expected-error at +2 {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be threadprivate or thread local, predetermined as linear}}
+ #pragma omp distribute simd
+ for (sii = 0; sii < 10; sii+=1)
+ c[sii] = a[sii];
+ }
+
+ #pragma omp parallel
+ {
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (globalii = 0; globalii < 10; globalii+=1)
+ c[globalii] = a[globalii];
+ }
+
+ #pragma omp parallel
+ {
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd collapse(2)
+ for (ii = 0; ii < 10; ii += 1)
+ for (globalii = 0; globalii < 10; globalii += 1)
+ c[globalii] += a[globalii] + ii;
+ }
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{statement after '#pragma omp distribute simd' must be a for loop}}
+ #pragma omp distribute simd
+ for (auto &item : a) {
+ item = item + 1;
+ }
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be positive due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (unsigned i = 9; i < 10; i--) {
+ c[i] = a[i] + b[i];
+ }
+
+ int (*lb)[4] = nullptr;
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (int (*p)[4] = lb; p < lb + 8; ++p) {
+ }
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-warning at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (int a{0}; a<10; ++a) {
+ }
+
+ return 0;
+}
+
+// Iterators allowed in openmp for-loops.
+namespace std {
+struct random_access_iterator_tag { };
+template <class Iter> struct iterator_traits {
+ typedef typename Iter::difference_type difference_type;
+ typedef typename Iter::iterator_category iterator_category;
+};
+template <class Iter>
+typename iterator_traits<Iter>::difference_type
+distance(Iter first, Iter last) { return first - last; }
+}
+class Iter0 {
+ public:
+ 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 at +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:
+ Iter1(float f=0.0f, double d=0.0) { }
+ Iter1(const Iter1 &) { }
+ Iter1 operator ++() { return *this; }
+ Iter1 operator --() { return *this; }
+ bool operator <(Iter1 a) { return true; }
+ bool operator >=(Iter1 a) { return false; }
+};
+class GoodIter {
+ public:
+ GoodIter() { }
+ GoodIter(const GoodIter &) { }
+ GoodIter(int fst, int snd) { }
+ GoodIter &operator =(const GoodIter &that) { return *this; }
+ GoodIter &operator =(const Iter0 &that) { return *this; }
+ GoodIter &operator +=(int x) { return *this; }
+ explicit GoodIter(void *) { }
+ GoodIter operator ++() { return *this; }
+ GoodIter operator --() { return *this; }
+ bool operator !() { return true; }
+ bool operator <(GoodIter a) { return true; }
+ bool operator <=(GoodIter a) { return true; }
+ bool operator >=(GoodIter a) { return false; }
+ typedef int difference_type;
+ typedef std::random_access_iterator_tag iterator_category;
+};
+// expected-note at +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 at +1 2 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
+GoodIter operator -(GoodIter a) { return a; }
+// expected-note at +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 at +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(); }
+
+int test_with_random_access_iterator() {
+ GoodIter begin, end;
+ Iter0 begin0, end0;
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (GoodIter I = begin; I < end; ++I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (GoodIter &I = begin; I < end; ++I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (GoodIter I = begin; I >= end; --I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-warning at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (GoodIter I(begin); I < end; ++I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-warning at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (GoodIter I(nullptr); I < end; ++I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-warning at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (GoodIter I(0); I < end; ++I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-warning at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (GoodIter I(1,2); I < end; ++I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (begin = GoodIter(0); begin < end; ++begin)
+ ++begin;
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (begin = GoodIter(1,2); begin < end; ++begin)
+ ++begin;
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (++begin; begin < end; ++begin)
+ ++begin;
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (begin = end; begin < end; ++begin)
+ ++begin;
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
+ #pragma omp distribute simd
+ for (GoodIter I = begin; I - I; ++I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
+ #pragma omp distribute simd
+ for (GoodIter I = begin; begin < end; ++I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
+ #pragma omp distribute simd
+ for (GoodIter I = begin; !I; ++I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be negative due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (GoodIter I = begin; I >= end; I = I + 1)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (GoodIter I = begin; I >= end; I = I - 1)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
+ #pragma omp distribute simd
+ for (GoodIter I = begin; I >= end; I = -I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be negative due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (GoodIter I = begin; I >= end; I = 2 + I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
+ #pragma omp distribute simd
+ for (GoodIter I = begin; I >= end; I = 2 - I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (Iter0 I = begin0; I < end0; ++I)
+ ++I;
+
+ #pragma omp target
+ #pragma omp teams
+ // Initializer is constructor without params.
+ // expected-warning at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (Iter0 I; I < end0; ++I)
+ ++I;
+
+ Iter1 begin1, end1;
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+ // expected-error at +2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
+ #pragma omp distribute simd
+ for (Iter1 I = begin1; I < end1; ++I)
+ ++I;
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be negative due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (Iter1 I = begin1; I >= end1; ++I)
+ ++I;
+
+ // Initializer is constructor with all default params.
+ #pragma omp target
+ #pragma omp teams
+ // expected-error at +4 {{invalid operands to binary expression ('Iter1' and 'float')}}
+ // expected-error at +3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
+ // expected-warning at +2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+ #pragma omp distribute simd
+ for (Iter1 I; I < end1; ++I) {
+ }
+
+ return 0;
+}
+
+template <typename IT, int ST> class TC {
+ public:
+ int dotest_lt(IT begin, IT end) {
+ // expected-note at +3 {{loop step is expected to be positive due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (IT I = begin; I < end; I = I + ST) {
+ ++I;
+ }
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be positive due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (IT I = begin; I <= end; I += ST) {
+ ++I;
+ }
+ #pragma omp distribute simd
+ for (IT I = begin; I < end; ++I) {
+ ++I;
+ }
+ }
+
+ static IT step() {
+ return IT(ST);
+ }
+};
+template <typename IT, int ST=0> int dotest_gt(IT begin, IT end) {
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 2 {{loop step is expected to be negative due to this condition}}
+ // expected-error at +2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (IT I = begin; I >= end; I = I + ST) {
+ ++I;
+ }
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 2 {{loop step is expected to be negative due to this condition}}
+ // expected-error at +2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (IT I = begin; I >= end; I += ST) {
+ ++I;
+ }
+
+ #pragma omp target
+ #pragma omp teams
+ // expected-note at +3 {{loop step is expected to be negative due to this condition}}
+ // expected-error at +2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+ #pragma omp distribute simd
+ for (IT I = begin; I >= end; ++I) {
+ ++I;
+ }
+
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (IT I = begin; I < end; I+=TC<int,ST>::step()) {
+ ++I;
+ }
+}
+
+void test_with_template() {
+ GoodIter begin, end;
+ TC<GoodIter, 100> t1;
+ TC<GoodIter, -100> t2;
+ t1.dotest_lt(begin, end);
+ t2.dotest_lt(begin, end); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
+ dotest_gt(begin, end); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
+ dotest_gt<unsigned, -10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, -10>' requested here}}
+}
+
+void test_loop_break() {
+ const int N = 100;
+ float a[N], b[N], c[N];
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (int i = 0; i < 10; i++) {
+ c[i] = a[i] + b[i];
+ for (int j = 0; j < 10; ++j) {
+ if (a[i] > b[j])
+ break; // OK in nested loop
+ }
+ switch(i) {
+ case 1:
+ b[i]++;
+ break;
+ default:
+ break;
+ }
+ if (c[i] > 10)
+ break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
+
+ if (c[i] > 11)
+ break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
+ }
+
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (int i = 0; i < 10; i++) {
+ for (int j = 0; j < 10; j++) {
+ c[i] = a[i] + b[i];
+ if (c[i] > 10) {
+ if (c[i] < 20) {
+ break; // OK
+ }
+ }
+ }
+ }
+}
+
+void test_loop_eh() {
+ const int N = 100;
+ float a[N], b[N], c[N];
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (int i = 0; i < 10; i++) {
+ c[i] = a[i] + b[i];
+ try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}
+ for (int j = 0; j < 10; ++j) {
+ if (a[i] > b[j])
+ throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+ }
+ throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+ }
+ catch (float f) {
+ if (f > 0.1)
+ throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+ return; // expected-error {{cannot return from OpenMP region}}
+ }
+ switch(i) {
+ case 1:
+ b[i]++;
+ break;
+ default:
+ break;
+ }
+ for (int j = 0; j < 10; j++) {
+ if (c[i] > 10)
+ throw c[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+ }
+ }
+ if (c[9] > 10)
+ throw c[9]; // OK
+
+ #pragma omp target
+ #pragma omp teams
+ #pragma omp distribute simd
+ for (int i = 0; i < 10; ++i) {
+ struct S {
+ void g() { throw 0; }
+ };
+ }
+}
+
Added: cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c?rev=275306&view=auto
==============================================================================
--- cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c (added)
+++ cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c Wed Jul 13 14:16:56 2016
@@ -0,0 +1,1091 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s
+
+// expected-error at +1 {{unexpected OpenMP directive '#pragma omp distribute simd'}}
+#pragma omp distribute simd
+
+// expected-error at +1 {{unexpected OpenMP directive '#pragma omp distribute simd'}}
+#pragma omp distribute simd foo
+
+// expected-error at +1 {{unexpected OpenMP directive '#pragma omp distribute simd'}}
+#pragma omp distribute simd safelen(4)
+
+void test_no_clause() {
+ int i;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{statement after '#pragma omp distribute simd' must be a for loop}}
+#pragma omp distribute simd
+ ++i;
+}
+
+void test_branch_protected_scope() {
+ int i = 0;
+L1:
+ ++i;
+
+ int x[24];
+
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd
+ for (i = 0; i < 16; ++i) {
+ if (i == 5)
+ goto L1; // expected-error {{use of undeclared label 'L1'}}
+ else if (i == 6)
+ return; // expected-error {{cannot return from OpenMP region}}
+ else if (i == 7)
+ goto L2;
+ else if (i == 8) {
+ L2:
+ x[i]++;
+ }
+ }
+
+ if (x[0] == 0)
+ goto L2; // expected-error {{use of undeclared label 'L2'}}
+ else if (x[1] == 1)
+ goto L1;
+}
+
+void test_invalid_clause() {
+ int i;
+#pragma omp target
+#pragma omp teams
+// expected-warning at +1 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+#pragma omp distribute simd foo bar
+ for (i = 0; i < 16; ++i)
+ ;
+}
+
+void test_non_identifiers() {
+ int i, x;
+
+#pragma omp target
+#pragma omp teams
+// expected-warning at +1 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+#pragma omp distribute simd;
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-warning at +1 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+#pragma omp distribute simd private(x);
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-warning at +1 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+#pragma omp distribute simd, private(x);
+ for (i = 0; i < 16; ++i)
+ ;
+}
+
+extern int foo();
+void test_safelen() {
+ int i;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected '('}}
+#pragma omp distribute simd safelen
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd safelen(
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd safelen()
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd safelen(,
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd safelen(, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-warning at +2 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+// expected-error at +1 {{expected '('}}
+#pragma omp distribute simd safelen 4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd safelen(4
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd safelen(4,
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd safelen(4, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// xxpected-error at +1 {{expected expression}}
+#pragma omp distribute simd safelen(4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd safelen(4 4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd safelen(4, , 4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd safelen(4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd safelen(4, 8)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expression is not an integer constant expression}}
+#pragma omp distribute simd safelen(2.5)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expression is not an integer constant expression}}
+#pragma omp distribute simd safelen(foo())
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument to 'safelen' clause must be a strictly positive integer value}}
+#pragma omp distribute simd safelen(-5)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument to 'safelen' clause must be a strictly positive integer value}}
+#pragma omp distribute simd safelen(0)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument to 'safelen' clause must be a strictly positive integer value}}
+#pragma omp distribute simd safelen(5 - 5)
+ for (i = 0; i < 16; ++i)
+ ;
+}
+
+void test_simdlen() {
+ int i;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected '('}}
+#pragma omp distribute simd simdlen
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd simdlen(
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd simdlen()
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd simdlen(,
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd simdlen(, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-warning at +2 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+// expected-error at +1 {{expected '('}}
+#pragma omp distribute simd simdlen 4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd simdlen(4
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd simdlen(4,
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd simdlen(4, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd simdlen(4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd simdlen(4 4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd simdlen(4, , 4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd simdlen(4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd simdlen(4, 8)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expression is not an integer constant expression}}
+#pragma omp distribute simd simdlen(2.5)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expression is not an integer constant expression}}
+#pragma omp distribute simd simdlen(foo())
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
+#pragma omp distribute simd simdlen(-5)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
+#pragma omp distribute simd simdlen(0)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
+#pragma omp distribute simd simdlen(5 - 5)
+ for (i = 0; i < 16; ++i)
+ ;
+}
+
+void test_collapse() {
+ int i;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected '('}}
+#pragma omp distribute simd collapse
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd collapse(
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd collapse()
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd collapse(,
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd collapse(, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-warning at +2 {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
+// expected-error at +1 {{expected '('}}
+#pragma omp distribute simd collapse 4)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}} expected-note at +1 {{as specified in 'collapse' clause}}
+#pragma omp distribute simd collapse(4
+ for (i = 0; i < 16; ++i)
+ ; // expected-error {{expected 4 for loops after '#pragma omp distribute simd', but found only 1}}
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}} expected-note at +1 {{as specified in 'collapse' clause}}
+#pragma omp distribute simd collapse(4,
+ for (i = 0; i < 16; ++i)
+ ; // expected-error {{expected 4 for loops after '#pragma omp distribute simd', but found only 1}}
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}} expected-note at +1 {{as specified in 'collapse' clause}}
+#pragma omp distribute simd collapse(4, )
+ for (i = 0; i < 16; ++i)
+ ; // expected-error {{expected 4 for loops after '#pragma omp distribute simd', but found only 1}}
+#pragma omp target
+#pragma omp teams
+// xxpected-error at +1 {{expected expression}} expected-note at +1 {{as specified in 'collapse' clause}}
+#pragma omp distribute simd collapse(4)
+ for (i = 0; i < 16; ++i)
+ ; // expected-error {{expected 4 for loops after '#pragma omp distribute simd', but found only 1}}
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}} expected-note at +1 {{as specified in 'collapse' clause}}
+#pragma omp distribute simd collapse(4 4)
+ for (i = 0; i < 16; ++i)
+ ; // expected-error {{expected 4 for loops after '#pragma omp distribute simd', but found only 1}}
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}} expected-note at +1 {{as specified in 'collapse' clause}}
+#pragma omp distribute simd collapse(4, , 4)
+ for (i = 0; i < 16; ++i)
+ ; // expected-error {{expected 4 for loops after '#pragma omp distribute simd', but found only 1}}
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd collapse(4)
+ for (int i1 = 0; i1 < 16; ++i1)
+ for (int i2 = 0; i2 < 16; ++i2)
+ for (int i3 = 0; i3 < 16; ++i3)
+ for (int i4 = 0; i4 < 16; ++i4)
+ foo();
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}}
+// expected-note at +1 {{to match this '('}} expected-note at +1 {{as specified in 'collapse' clause}}
+#pragma omp distribute simd collapse(4, 8)
+ for (i = 0; i < 16; ++i)
+ ; // expected-error {{expected 4 for loops after '#pragma omp distribute simd', but found only 1}}
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expression is not an integer constant expression}}
+#pragma omp distribute simd collapse(2.5)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expression is not an integer constant expression}}
+#pragma omp distribute simd collapse(foo())
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument to 'collapse' clause must be a strictly positive integer value}}
+#pragma omp distribute simd collapse(-5)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument to 'collapse' clause must be a strictly positive integer value}}
+#pragma omp distribute simd collapse(0)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument to 'collapse' clause must be a strictly positive integer value}}
+#pragma omp distribute simd collapse(5 - 5)
+ for (i = 0; i < 16; ++i)
+ ;
+// expected-note at +3 {{defined as reduction}}
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd collapse(2) reduction(+ : i)
+ for (i = 0; i < 16; ++i)
+ // expected-note at +1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
+ for (int j = 0; j < 16; ++j)
+// expected-error at +2 2 {{reduction variable must be shared}}
+// expected-error at +1 {{OpenMP constructs may not be nested inside a simd region}}
+#pragma omp for reduction(+ : i, j)
+ for (int k = 0; k < 16; ++k)
+ i += j;
+
+#pragma omp target
+#pragma omp teams
+ for (i = 0; i < 16; ++i)
+ for (int j = 0; j < 16; ++j)
+#pragma omp distribute simd reduction(+ : i, j)
+ for (int k = 0; k < 16; ++k)
+ i += j;
+}
+
+void test_linear() {
+ int i;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd linear(
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected expression}}
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd linear(,
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected expression}}
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd linear(, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd linear()
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd linear(int)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected variable name}}
+#pragma omp distribute simd linear(0)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{use of undeclared identifier 'x'}}
+#pragma omp distribute simd linear(x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{use of undeclared identifier 'x'}}
+// expected-error at +1 {{use of undeclared identifier 'y'}}
+#pragma omp distribute simd linear(x, y)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +3 {{use of undeclared identifier 'x'}}
+// expected-error at +2 {{use of undeclared identifier 'y'}}
+// expected-error at +1 {{use of undeclared identifier 'z'}}
+#pragma omp distribute simd linear(x, y, z)
+ for (i = 0; i < 16; ++i)
+ ;
+
+ int x, y;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd linear(x :)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd linear(x :, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd linear(x : 1)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd linear(x : 2 * 2)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd linear(x : 1, y)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd linear(x : 1, y, z : 1)
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-note at +2 {{defined as linear}}
+// expected-error at +1 {{linear variable cannot be linear}}
+#pragma omp distribute simd linear(x) linear(x)
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-note at +2 {{defined as private}}
+// expected-error at +1 {{private variable cannot be linear}}
+#pragma omp distribute simd private(x) linear(x)
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-note at +2 {{defined as linear}}
+// expected-error at +1 {{linear variable cannot be private}}
+#pragma omp distribute simd linear(x) private(x)
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-warning at +1 {{zero linear step (x and other variables in clause should probably be const)}}
+#pragma omp distribute simd linear(x, y : 0)
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-note at +2 {{defined as linear}}
+// expected-error at +1 {{linear variable cannot be lastprivate}}
+#pragma omp distribute simd linear(x) lastprivate(x)
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-note at +2 {{defined as lastprivate}}
+// expected-error at +1 {{lastprivate variable cannot be linear}}
+#pragma omp distribute simd lastprivate(x) linear(x)
+ for (i = 0; i < 16; ++i)
+ ;
+}
+
+void test_aligned() {
+ int i;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd aligned(
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected expression}}
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd aligned(,
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected expression}}
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd aligned(, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd aligned()
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd aligned(int)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected variable name}}
+#pragma omp distribute simd aligned(0)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{use of undeclared identifier 'x'}}
+#pragma omp distribute simd aligned(x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{use of undeclared identifier 'x'}}
+// expected-error at +1 {{use of undeclared identifier 'y'}}
+#pragma omp distribute simd aligned(x, y)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +3 {{use of undeclared identifier 'x'}}
+// expected-error at +2 {{use of undeclared identifier 'y'}}
+// expected-error at +1 {{use of undeclared identifier 'z'}}
+#pragma omp distribute simd aligned(x, y, z)
+ for (i = 0; i < 16; ++i)
+ ;
+
+ int *x, y, z[25]; // expected-note 4 {{'y' defined here}}
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd aligned(x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd aligned(z)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd aligned(x :)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}} expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd aligned(x :, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd aligned(x : 1)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd aligned(x : 2 * 2)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd aligned(x : 1, y)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd aligned(x : 1, y, z : 1)
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp distribute simd aligned(x, y)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp distribute simd aligned(x, y, z)
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-note at +2 {{defined as aligned}}
+// expected-error at +1 {{a variable cannot appear in more than one aligned clause}}
+#pragma omp distribute simd aligned(x) aligned(z, x)
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-note at +3 {{defined as aligned}}
+// expected-error at +2 {{a variable cannot appear in more than one aligned clause}}
+// expected-error at +1 2 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp distribute simd aligned(x, y, z) aligned(y, z)
+ for (i = 0; i < 16; ++i)
+ ;
+}
+
+void test_private() {
+ int i;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected expression}}
+// expected-error at +1 {{expected ')'}} expected-note at +1 {{to match this '('}}
+#pragma omp distribute simd private(
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}} expected-note at +2 {{to match this '('}}
+// expected-error at +1 2 {{expected expression}}
+#pragma omp distribute simd private(,
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 2 {{expected expression}}
+#pragma omp distribute simd private(, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd private()
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd private(int)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected variable name}}
+#pragma omp distribute simd private(0)
+ for (i = 0; i < 16; ++i)
+ ;
+
+ int x, y, z;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd private(x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd private(x, y)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd private(x, y, z)
+ for (i = 0; i < 16; ++i) {
+ x = y * i + z;
+ }
+}
+
+void test_firstprivate() {
+ int i;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}} expected-note at +2 {{to match this '('}}
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd firstprivate(
+ for (i = 0; i < 16; ++i)
+ ;
+}
+
+void test_lastprivate() {
+ int i;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}} expected-note at +2 {{to match this '('}}
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd lastprivate(
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected ')'}} expected-note at +2 {{to match this '('}}
+// expected-error at +1 2 {{expected expression}}
+#pragma omp distribute simd lastprivate(,
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 2 {{expected expression}}
+#pragma omp distribute simd lastprivate(, )
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd lastprivate()
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd lastprivate(int)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected variable name}}
+#pragma omp distribute simd lastprivate(0)
+ for (i = 0; i < 16; ++i)
+ ;
+
+ int x, y, z;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd lastprivate(x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd lastprivate(x, y)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd lastprivate(x, y, z)
+ for (i = 0; i < 16; ++i)
+ ;
+}
+
+void test_reduction() {
+ int i, x, y;
+#pragma omp target
+#pragma omp teams
+// expected-error at +3 {{expected ')'}} expected-note at +3 {{to match this '('}}
+// expected-error at +2 {{expected identifier}}
+// expected-warning at +1 {{missing ':' after reduction identifier - ignoring}}
+#pragma omp distribute simd reduction(
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected identifier}}
+// expected-warning at +1 {{missing ':' after reduction identifier - ignoring}}
+#pragma omp distribute simd reduction()
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{expected expression}}
+// expected-warning at +1 {{missing ':' after reduction identifier - ignoring}}
+#pragma omp distribute simd reduction(x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected identifier}}
+#pragma omp distribute simd reduction( : x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +3 {{expected ')'}} expected-note at +3 {{to match this '('}}
+// expected-error at +2 {{expected identifier}}
+// expected-warning at +1 {{missing ':' after reduction identifier - ignoring}}
+#pragma omp distribute simd reduction(,
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +3 {{expected ')'}} expected-note at +3 {{to match this '('}}
+// expected-error at +2 {{expected expression}}
+// expected-warning at +1 {{missing ':' after reduction identifier - ignoring}}
+#pragma omp distribute simd reduction(+
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+// expected-error at +3 {{expected ')'}} expected-note at +3 {{to match this '('}}
+//
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd reduction(+:
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd reduction(+ :)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd reduction(+ :, y)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected expression}}
+#pragma omp distribute simd reduction(+ : x, + : y)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected identifier}}
+#pragma omp distribute simd reduction(% : x)
+ for (i = 0; i < 16; ++i)
+ ;
+
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(+ : x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(* : x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(- : x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(& : x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(| : x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(^ : x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(&& : x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(|| : x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(max : x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(min : x)
+ for (i = 0; i < 16; ++i)
+ ;
+ struct X {
+ int x;
+ };
+ struct X X;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected variable name}}
+#pragma omp distribute simd reduction(+ : X.x)
+ for (i = 0; i < 16; ++i)
+ ;
+#pragma omp target
+#pragma omp teams
+// expected-error at +1 {{expected variable name}}
+#pragma omp distribute simd reduction(+ : x + x)
+ for (i = 0; i < 16; ++i)
+ ;
+}
+
+void test_loop_messages() {
+ float a[100], b[100], c[100];
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{variable must be of integer or pointer type}}
+#pragma omp distribute simd
+ for (float fi = 0; fi < 10.0; fi++) {
+ c[(int)fi] = a[(int)fi] + b[(int)fi];
+ }
+#pragma omp target
+#pragma omp teams
+// expected-error at +2 {{variable must be of integer or pointer type}}
+#pragma omp distribute simd
+ for (double fi = 0; fi < 10.0; fi++) {
+ c[(int)fi] = a[(int)fi] + b[(int)fi];
+ }
+}
+
+void linear_modifiers(int argc) {
+ int f;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd linear(f)
+ for (int k = 0; k < argc; ++k) ++k;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd linear(val(f))
+ for (int k = 0; k < argc; ++k) ++k;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd linear(uval(f)) // expected-error {{expected 'val' modifier}}
+ for (int k = 0; k < argc; ++k) ++k;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd linear(ref(f)) // expected-error {{expected 'val' modifier}}
+ for (int k = 0; k < argc; ++k) ++k;
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd linear(foo(f)) // expected-error {{expected 'val' modifier}}
+ for (int k = 0; k < argc; ++k) ++k;
+}
+
More information about the cfe-commits
mailing list