| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-fno-tree-dse -O1 -ftrivial-auto-var-init=pattern" } |
| 3 |
|
| 4 |
class A; |
| 5 |
template <typename _Tp, int m, int n> class B { |
| 6 |
public: |
| 7 |
_Tp val[m * n]; |
| 8 |
}; |
| 9 |
class C { |
| 10 |
public: |
| 11 |
C(A); |
| 12 |
}; |
| 13 |
struct D { |
| 14 |
D(); |
| 15 |
unsigned long &operator[](int); |
| 16 |
unsigned long *p; |
| 17 |
}; |
| 18 |
class A { |
| 19 |
public: |
| 20 |
template <typename _Tp, int m, int n> A(const B<_Tp, m, n> &, bool); |
| 21 |
int rows, cols; |
| 22 |
unsigned char *data; |
| 23 |
unsigned char *datastart; |
| 24 |
unsigned char *dataend; |
| 25 |
unsigned char *datalimit; |
| 26 |
D step; |
| 27 |
}; |
| 28 |
template <typename _Tp, int m, int n> |
| 29 |
A::A(const B<_Tp, m, n> &p1, bool) |
| 30 |
: rows(m), cols(n) { |
| 31 |
step[0] = cols * sizeof(_Tp); |
| 32 |
datastart = data = (unsigned char *)p1.val; |
| 33 |
datalimit = dataend = datastart + rows * step[0]; |
| 34 |
} |
| 35 |
class F { |
| 36 |
public: |
| 37 |
static void compute(C); |
| 38 |
template <typename _Tp, int m, int n, int nm> |
| 39 |
static void compute(const B<_Tp, m, n> &, B<_Tp, nm, 1> &, B<_Tp, m, nm> &, |
| 40 |
B<_Tp, n, nm> &); |
| 41 |
}; |
| 42 |
D::D() {} |
| 43 |
unsigned long &D::operator[](int p1) { return p[p1]; } |
| 44 |
template <typename _Tp, int m, int n, int nm> |
| 45 |
void F::compute(const B<_Tp, m, n> &, B<_Tp, nm, 1> &, B<_Tp, m, nm> &, |
| 46 |
B<_Tp, n, nm> &p4) { |
| 47 |
A a(p4, false); |
| 48 |
compute(a); |
| 49 |
} |
| 50 |
void fn1() { |
| 51 |
B<double, 4, 4> b, c, e; |
| 52 |
B<double, 4, 1> d; |
| 53 |
F::compute(b, d, c, e); |
| 54 |
} |