// { dg-do run } typedef __PTRDIFF_TYPE__ ptrdiff_t; extern "C" void abort (); template class I { public: typedef ptrdiff_t difference_type; I (); ~I (); I (T *); I (const I &); T &operator * (); T *operator -> (); T &operator [] (const difference_type &) const; I &operator = (const I &); I &operator ++ (); I operator ++ (int); I &operator -- (); I operator -- (int); I &operator += (const difference_type &); I &operator -= (const difference_type &); I operator + (const difference_type &) const; I operator - (const difference_type &) const; template friend bool operator == (I &, I &); template friend bool operator == (const I &, const I &); template friend bool operator < (I &, I &); template friend bool operator < (const I &, const I &); template friend bool operator <= (I &, I &); template friend bool operator <= (const I &, const I &); template friend bool operator > (I &, I &); template friend bool operator > (const I &, const I &); template friend bool operator >= (I &, I &); template friend bool operator >= (const I &, const I &); template friend typename I::difference_type operator - (I &, I &); template friend typename I::difference_type operator - (const I &, const I &); template friend I operator + (typename I::difference_type , const I &); private: T *p; }; template I::I () : p (0) {} template I::~I () {} template I::I (T *x) : p (x) {} template I::I (const I &x) : p (x.p) {} template T &I::operator * () { return *p; } template T *I::operator -> () { return p; } template T &I::operator [] (const difference_type &x) const { return p[x]; } template I &I::operator = (const I &x) { p = x.p; return *this; } template I &I::operator ++ () { ++p; return *this; } template I I::operator ++ (int) { return I (p++); } template I &I::operator -- () { --p; return *this; } template I I::operator -- (int) { return I (p--); } template I &I::operator += (const difference_type &x) { p += x; return *this; } template I &I::operator -= (const difference_type &x) { p -= x; return *this; } template I I::operator + (const difference_type &x) const { return I (p + x); } template I I::operator - (const difference_type &x) const { return I (p - x); } template bool operator == (I &x, I &y) { return x.p == y.p; } template bool operator == (const I &x, const I &y) { return x.p == y.p; } template bool operator != (I &x, I &y) { return !(x == y); } template bool operator != (const I &x, const I &y) { return !(x == y); } template bool operator < (I &x, I &y) { return x.p < y.p; } template bool operator < (const I &x, const I &y) { return x.p < y.p; } template bool operator <= (I &x, I &y) { return x.p <= y.p; } template bool operator <= (const I &x, const I &y) { return x.p <= y.p; } template bool operator > (I &x, I &y) { return x.p > y.p; } template bool operator > (const I &x, const I &y) { return x.p > y.p; } template bool operator >= (I &x, I &y) { return x.p >= y.p; } template bool operator >= (const I &x, const I &y) { return x.p >= y.p; } template typename I::difference_type operator - (I &x, I &y) { return x.p - y.p; } template typename I::difference_type operator - (const I &x, const I &y) { return x.p - y.p; } template I operator + (typename I::difference_type x, const I &y) { return I (x + y.p); } template class J { public: J(const I &x, const I &y) : b (x), e (y) {} const I &begin (); const I &end (); private: I b, e; }; template const I &J::begin () { return b; } template const I &J::end () { return e; } int results[2000]; template static inline void baz (I &i) { results[*i]++; } void f1 (const I &x, const I &y) { #pragma omp parallel loop order(concurrent) for (I i = x; i <= y; i += 6) baz (i); } void f2 (const I &x, const I &y) { I i; #pragma omp loop private(i) bind(parallel) for (i = x; i < y - 1; i = 1 - 6 + 7 + i) baz (i); } template void f3 (const I &x, const I &y) { #pragma omp loop bind(thread) order(concurrent) for (I i = x; i <= y; i = i + 9 - 8) baz (i); } template void f4 (const I &x, const I &y) { I i; #pragma omp parallel loop lastprivate(i) for (i = x + 2000 - 64; i > y + 10; --i) baz (i); } void f5 (const I &x, const I &y) { #pragma omp loop bind(teams) for (I i = x + 2000 - 64; i > y + 10; i -= 10) baz (i); } template void f6 (const I &x, const I &y) { I i; #pragma omp teams loop order(concurrent) for (i = x + 2000 - 64; i > y + 10; i = i - 12 + 2) { I j = i + N; baz (j); } } template void f7 (I i, const I &x, const I &y) { #pragma omp master #pragma omp loop for (i = x - 10; i <= y + 10; i += N) baz (i); } template void f8 (J j) { I i; #pragma omp parallel loop for (i = j.begin (); i <= j.end () + N; i += 2) baz (i); } template void f9 (const I &x, const I &y) { I i; #pragma omp loop bind(teams) private(i) for (i = x; i <= y; i = i + N) baz (i); } template void f10 (const I &x, const I &y) { I i; #pragma omp loop bind(thread) private(i) for (i = x; i > y; i = i + N) baz (i); } template void f11 (const T &x, const T &y) { #pragma omp parallel { #pragma omp loop for (T i = x; i <= y; i += 3) baz (i); #pragma omp single { T j = y + 3; baz (j); } } } template void f12 (const T &x, const T &y) { T i; #pragma omp loop lastprivate(i) bind(thread) for (i = x; i > y; --i) baz (i); } template struct K { template static void f13 (const T &x, const T &y) { T i; #pragma omp teams loop order(concurrent) bind(teams) lastprivate (i) for (i = x; i <= y + N; i += N) baz (i); } }; #define check(expr) \ for (int i = 0; i < 2000; i++) \ if (expr) \ { \ if (results[i] != 1) \ abort (); \ results[i] = 0; \ } \ else if (results[i]) \ abort () int main () { int a[2000]; long b[2000]; for (int i = 0; i < 2000; i++) { a[i] = i; b[i] = i; } f1 (&a[10], &a[1990]); check (i >= 10 && i <= 1990 && (i - 10) % 6 == 0); #pragma omp parallel f2 (&a[0], &a[1999]); check (i < 1998 && (i & 1) == 0); f3 (&a[20], &a[1837]); check (i >= 20 && i <= 1837); f4 (&a[0], &a[30]); check (i > 40 && i <= 2000 - 64); #pragma omp teams f5 (&a[0], &a[100]); check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); f6<-10> (&a[10], &a[110]); check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0); #pragma omp parallel num_threads(2) f7<6> (I (), &a[12], &a[1800]); check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0); f8<121> (J (&a[14], &a[1803])); check (i >= 14 && i <= 1924 && (i & 1) == 0); #pragma omp teams f9 (&a[33], &a[1967]); check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); f10 (&a[1939], &a[17]); check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); f11 > (&a[16], &a[1981]); check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); f12 > (&a[1761], &a[37]); check (i > 37 && i <= 1761); K<5>::f13 > (&a[1], &a[1935]); check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); #pragma omp teams f9 (&b[33], &b[1967]); check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0); f10 (&b[1939], &b[17]); check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0); f11 > (&b[16], &b[1981]); check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0); f12 > (&b[1761], &b[37]); check (i > 37 && i <= 1761); K<5>::f13 > (&b[1], &b[1935]); check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0); }