aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/member-5.C
blob: d6fec7a841a700faf1f5abece1478453e2832777 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// { dg-do run }

typedef __PTRDIFF_TYPE__ ptrdiff_t;

template <typename T>
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 <typename S> friend bool operator == (I<S> &, I<S> &);
  template <typename S> friend bool operator == (const I<S> &, const I<S> &);
  template <typename S> friend bool operator < (I<S> &, I<S> &);
  template <typename S> friend bool operator < (const I<S> &, const I<S> &);
  template <typename S> friend bool operator <= (I<S> &, I<S> &);
  template <typename S> friend bool operator <= (const I<S> &, const I<S> &);
  template <typename S> friend bool operator > (I<S> &, I<S> &);
  template <typename S> friend bool operator > (const I<S> &, const I<S> &);
  template <typename S> friend bool operator >= (I<S> &, I<S> &);
  template <typename S> friend bool operator >= (const I<S> &, const I<S> &);
  template <typename S> friend typename I<S>::difference_type operator - (I<S> &, I<S> &);
  template <typename S> friend typename I<S>::difference_type operator - (const I<S> &, const I<S> &);
  template <typename S> friend I<S> operator + (typename I<S>::difference_type , const I<S> &);
private:
  T *p;
};
template <typename T> I<T>::I () : p (0) {}
template <typename T> I<T>::~I () {}
template <typename T> I<T>::I (T *x) : p (x) {}
template <typename T> I<T>::I (const I &x) : p (x.p) {}
template <typename T> T &I<T>::operator * () { return *p; }
template <typename T> T *I<T>::operator -> () { return p; }
template <typename T> T &I<T>::operator [] (const difference_type &x) const { return p[x]; }
template <typename T> I<T> &I<T>::operator = (const I &x) { p = x.p; return *this; }
template <typename T> I<T> &I<T>::operator ++ () { ++p; return *this; }
template <typename T> I<T> I<T>::operator ++ (int) { return I (p++); }
template <typename T> I<T> &I<T>::operator -- () { --p; return *this; }
template <typename T> I<T> I<T>::operator -- (int) { return I (p--); }
template <typename T> I<T> &I<T>::operator += (const difference_type &x) { p += x; return *this; }
template <typename T> I<T> &I<T>::operator -= (const difference_type &x) { p -= x; return *this; }
template <typename T> I<T> I<T>::operator + (const difference_type &x) const { return I (p + x); }
template <typename T> I<T> I<T>::operator - (const difference_type &x) const { return I (p - x); }
template <typename T> bool operator == (I<T> &x, I<T> &y) { return x.p == y.p; }
template <typename T> bool operator == (const I<T> &x, const I<T> &y) { return x.p == y.p; }
template <typename T> bool operator != (I<T> &x, I<T> &y) { return !(x == y); }
template <typename T> bool operator != (const I<T> &x, const I<T> &y) { return !(x == y); }
template <typename T> bool operator < (I<T> &x, I<T> &y) { return x.p < y.p; }
template <typename T> bool operator < (const I<T> &x, const I<T> &y) { return x.p < y.p; }
template <typename T> bool operator <= (I<T> &x, I<T> &y) { return x.p <= y.p; }
template <typename T> bool operator <= (const I<T> &x, const I<T> &y) { return x.p <= y.p; }
template <typename T> bool operator > (I<T> &x, I<T> &y) { return x.p > y.p; }
template <typename T> bool operator > (const I<T> &x, const I<T> &y) { return x.p > y.p; }
template <typename T> bool operator >= (I<T> &x, I<T> &y) { return x.p >= y.p; }
template <typename T> bool operator >= (const I<T> &x, const I<T> &y) { return x.p >= y.p; }
template <typename T> typename I<T>::difference_type operator - (I<T> &x, I<T> &y) { return x.p - y.p; }
template <typename T> typename I<T>::difference_type operator - (const I<T> &x, const I<T> &y) { return x.p - y.p; }
template <typename T> I<T> operator + (typename I<T>::difference_type x, const I<T> &y) { return I<T> (x + y.p); }

struct R { R () {}; ~R () {}; I<int> r; };
struct T { T () {}; virtual ~T () {}; I<int> t; };
struct A : public R, virtual public T { A () {} I<int> a; void m1 (const I<int> &, const I<int> &); };
template <typename Q>
struct U { U () {}; virtual ~U () {}; Q t; };
template <typename Q>
struct B : public R, virtual public U<Q> { B () {} Q a; void m2 (const Q &, const Q &, const I<int> &, const I<int> &); };

int d[64];

void
A::m1 (const I<int> &x, const I<int> &y)
{
  int w = 0;
  #pragma omp parallel for private (a) reduction(|:w)
  for (a = x; A::a < y - 33; a += 2)
    w |= (1 << *A::a);
  if (w != 0x55555555)
    __builtin_abort ();
  #pragma omp parallel for lastprivate (t)
  for (T::t = x; t < y - 32; t += 3)
    d[*T::t + 2] |= 1;
  if (*T::t != 33)
    __builtin_abort ();
  for (int i = 0; i < 64; i++)
    if (d[i] != ((i >= 2 && i < 32 + 2 && (i - 2) % 3 == 0) ? 1 : 0))
      __builtin_abort ();
  w = 0;
  #pragma omp parallel for reduction(|:w)
  for (a = x; A::a < y - 33; a += 2)
    w |= (1 << *A::a);
  if (w != 0x55555555)
    __builtin_abort ();
  #pragma omp taskloop
  for (R::r = x; r < y - 32; R::r += 2)
    d[*r + 8] |= 2;
  for (int i = 0; i < 64; i++)
    if (d[i] != (((i >= 2 && i < 32 + 2 && (i - 2) % 3 == 0) ? 1 : 0)
		 | ((i >= 8 && i < 32 + 8 && (i & 1) == 0) ? 2 : 0)))
      __builtin_abort ();
  #pragma omp taskloop collapse(2)
  for (T::t = x; t < y - 57; t += 2)
    for (a = x; A::a < y - 56; a++)
      d[((*t << 2) | *a) + 3] |= 4;
  for (int i = 0; i < 64; i++)
    if (d[i] != (((i >= 2 && i < 32 + 2 && (i - 2) % 3 == 0) ? 1 : 0)
		 | ((i >= 8 && i < 32 + 8 && (i & 1) == 0) ? 2 : 0)
		 | ((i >= 3 && i < 32 + 3) ? 4 : 0)))
      __builtin_abort ();
}

template <typename Q>
void
B<Q>::m2 (const Q &u, const Q &v, const I<int> &x, const I<int> &y)
{
  int w = 0;
  #pragma omp parallel for private (a) reduction(|:w)
  for (a = u; B::a < v - 33; a += 2)
    w |= (1 << *B::a);
  if (w != 0x55555555)
    __builtin_abort ();
  #pragma omp parallel for lastprivate (U<Q>::t)
  for (U<Q>::t = u; U<Q>::t < v - 32; U<Q>::t += 3)
    d[*U<Q>::t + 2] |= 1;
  if (*U<Q>::t != 33)
    __builtin_abort ();
  for (int i = 0; i < 64; i++)
    if (d[i] != ((i >= 2 && i < 32 + 2 && (i - 2) % 3 == 0) ? 1 : 0))
      __builtin_abort ();
  w = 0;
  #pragma omp parallel for reduction(|:w)
  for (a = u; B::a < v - 33; a += 2)
    w |= (1 << *B::a);
  if (w != 0x55555555)
    __builtin_abort ();
  #pragma omp taskloop
  for (R::r = x; r < y - 32; R::r += 2)
    d[*r + 8] |= 2;
  for (int i = 0; i < 64; i++)
    if (d[i] != (((i >= 2 && i < 32 + 2 && (i - 2) % 3 == 0) ? 1 : 0)
		 | ((i >= 8 && i < 32 + 8 && (i & 1) == 0) ? 2 : 0)))
      __builtin_abort ();
  #pragma omp taskloop collapse(2)
  for (U<Q>::t = u; U<Q>::t < v - 57; U<Q>::t += 2)
    for (a = u; B::a < v - 56; a++)
      d[((*U<Q>::t << 2) | *a) + 3] |= 4;
  for (int i = 0; i < 64; i++)
    if (d[i] != (((i >= 2 && i < 32 + 2 && (i - 2) % 3 == 0) ? 1 : 0)
		 | ((i >= 8 && i < 32 + 8 && (i & 1) == 0) ? 2 : 0)
		 | ((i >= 3 && i < 32 + 3) ? 4 : 0)))
      __builtin_abort ();
}

int
main ()
{
  A a;
  int b[128];
  for (int i = 0; i < 128; i++)
    b[i] = i - 32;
  a.m1 (&b[32], &b[96]);
  for (int i = 0; i < 64; i++)
    d[i] = 0;
  B<I<int> > c;
  c.m2 (&b[32], &b[96], &b[32], &b[96]);
  for (int i = 0; i < 64; i++)
    d[i] = 0;
  B<int *> d;
  d.m2 (&b[32], &b[96], &b[32], &b[96]);
}