Debian Codegraph @

gcc/testsuite/g++.dg/gomp/loop-8.C

raw
1 typedef __PTRDIFF_TYPE__ ptrdiff_t;
2
3 template <typename T>
4 class I
5 {
6 public:
7 typedef ptrdiff_t difference_type;
8 I ();
9 ~I ();
10 I (T *);
11 I (const I &);
12 T &operator * ();
13 T *operator -> ();
14 T &operator [] (const difference_type &) const;
15 I &operator = (const I &);
16 I &operator ++ ();
17 I operator ++ (int);
18 I &operator -- ();
19 I operator -- (int);
20 I &operator += (const difference_type &);
21 I &operator -= (const difference_type &);
22 I operator + (const difference_type &) const;
23 I operator - (const difference_type &) const;
24 template <typename S> friend bool operator == (I<S> &, I<S> &);
25 template <typename S> friend bool operator == (const I<S> &, const I<S> &);
26 template <typename S> friend bool operator < (I<S> &, I<S> &);
27 template <typename S> friend bool operator < (const I<S> &, const I<S> &);
28 template <typename S> friend bool operator <= (I<S> &, I<S> &);
29 template <typename S> friend bool operator <= (const I<S> &, const I<S> &);
30 template <typename S> friend bool operator > (I<S> &, I<S> &);
31 template <typename S> friend bool operator > (const I<S> &, const I<S> &);
32 template <typename S> friend bool operator >= (I<S> &, I<S> &);
33 template <typename S> friend bool operator >= (const I<S> &, const I<S> &);
34 template <typename S> friend typename I<S>::difference_type operator - (I<S> &, I<S> &);
35 template <typename S> friend typename I<S>::difference_type operator - (const I<S> &, const I<S> &);
36 template <typename S> friend I<S> operator + (typename I<S>::difference_type , const I<S> &);
37 private:
38 T *p;
39 };
40
41 template <typename T> bool operator == (I<T> &, I<T> &);
42 template <typename T> bool operator == (const I<T> &, const I<T> &);
43 template <typename T> bool operator != (I<T> &, I<T> &);
44 template <typename T> bool operator != (const I<T> &, const I<T> &);
45 template <typename T> bool operator < (I<T> &, I<T> &);
46 template <typename T> bool operator < (const I<T> &, const I<T> &);
47 template <typename T> bool operator <= (I<T> &, I<T> &);
48 template <typename T> bool operator <= (const I<T> &, const I<T> &);
49 template <typename T> bool operator > (I<T> &, I<T> &);
50 template <typename T> bool operator > (const I<T> &, const I<T> &);
51 template <typename T> bool operator >= (I<T> &, I<T> &);
52 template <typename T> bool operator >= (const I<T> &, const I<T> &);
53 template <typename T> typename I<T>::difference_type operator - (I<T> &, I<T> &);
54 template <typename T> typename I<T>::difference_type operator - (const I<T> &, const I<T> &);
55 template <typename T> I<T> operator + (typename I<T>::difference_type, const I<T> &);
56
57 extern I<int> i, j;
58 #pragma omp threadprivate (i, j)
59 extern I<int> k, l;
60 #pragma omp threadprivate (k, l)
61 I<int> k, l;
62
63 void
64 f1 (I<int> &x, I<int> &y)
65 {
66 #pragma omp for collapse(2)
67 for (i = x; i < y; i++) // { dg-error "expected iteration declaration or initialization" }
68 for (j = x; j < y; j++)
69 ;
70 }
71
72 void
73 f2 (I<int> &x, I<int> &y)
74 {
75 #pragma omp for collapse(2)
76 for (k = x; k < y; k++) // { dg-error "expected iteration declaration or initialization" }
77 for (l = x; l < y; l++)
78 ;
79 }
80
81 template <int N>
82 void
83 f3 (I<int> &x, I<int> &y)
84 {
85 #pragma omp for collapse(2)
86 for (i = x; i < y; i++) // { dg-error "'i' is predetermined 'threadprivate' for 'private'" }
87 for (j = x; j < y; j++) // { dg-error "'j' is predetermined 'threadprivate' for 'private'" }
88 ;
89 }
90
91 template <int N>
92 void
93 f4 (I<int> &x, I<int> &y)
94 {
95 #pragma omp for collapse(2)
96 for (k = x; k < y; k++) // { dg-error "'k' is predetermined 'threadprivate' for 'private'" }
97 for (l = x; l < y; l++) // { dg-error "'l' is predetermined 'threadprivate' for 'private'" }
98 ;
99 }
100
101 template <typename T>
102 void
103 f5 (I<T> &x, I<T> &y)
104 {
105 #pragma omp for collapse(2) // { dg-error "expected iteration declaration or initialization" }
106 for (i = x; i < y; i++) // { dg-error "'i' is predetermined 'threadprivate' for 'private'" }
107 for (j = x; j < y; j++) // { dg-error "'j' is predetermined 'threadprivate' for 'private'" }
108 ;
109 }
110
111 template <typename T>
112 void
113 f6 (I<T> &x, I<T> &y)
114 {
115 #pragma omp for collapse(2) // { dg-error "expected iteration declaration or initialization" }
116 for (k = x; k < y; k++) // { dg-error "'k' is predetermined 'threadprivate' for 'private'" }
117 for (l = x; l < y; l++) // { dg-error "'l' is predetermined 'threadprivate' for 'private'" }
118 ;
119 }
120
121 void
122 test (I<int> &x, I<int> &y)
123 {
124 f3<0> (x, y);
125 f4<0> (x, y);
126 f5 (x, y);
127 f6 (x, y);
128 }