aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/torture/pr54735.C
blob: 0604ec5179b4de88760349dbe0a75ad280a74eed (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
// { dg-do compile }

class Gmpfr
{};
class M : Gmpfr
{
public:
  Gmpfr infconst;
  M(int);
};
template<typename>struct A;
template<typename, int, int, int = 0 ? : 0, int = 0, int = 0>class N;
template<typename>class O;
template<typename>struct B;
struct C
{
  enum
  { value };
};
class D
{
public:
  enum
  { ret };
};
struct F
{
  enum
  { ret = 0 ? : 0 };
};
template<typename Derived>struct G
{
  typedef O<Derived>type;
};
struct H
{
  void operator * ();
};
struct I
{
  enum
  { RequireInitialization = C::value ? : 0, ReadCost };
};
template<typename Derived>struct J
{
  enum
  { ret = A<Derived>::InnerStrideAtCompileTime };
};
template<typename Derived>struct K
{
  enum
  { ret = A<Derived>::OuterStrideAtCompileTime };
};
template<typename Derived>class P : H
{
public:
  using H::operator *;
  typedef typename A<Derived>::Scalar Scalar;
  enum
  { RowsAtCompileTime                                        =
      A<Derived>::RowsAtCompileTime, ColsAtCompileTime       =
      A<Derived>::ColsAtCompileTime, SizeAtCompileTime       =
      F::ret, MaxRowsAtCompileTime                           =
      A<Derived>::MaxRowsAtCompileTime, MaxColsAtCompileTime =
      A<Derived>::MaxColsAtCompileTime, MaxSizeAtCompileTime =
      F::ret, Flags                                          =
      A<Derived>::Flags ? : 0 ? : 0, CoeffReadCost           =
      A<Derived>::CoeffReadCost, InnerStrideAtCompileTime    =
      J<Derived>::ret, OuterStrideAtCompileTime              = K<Derived>::ret };
  B<Derived> operator << (const Scalar&);
};

template<typename Derived>class O : public P<Derived>
{};

template<int _Cols>class L
{
public:

  int cols()
  {
    return _Cols;
  }
};
template<typename Derived>class Q : public G<Derived>::type
{
public:
  typedef typename G<Derived>::type   Base;
  typedef typename A<Derived>::Index  Index;
  typedef typename A<Derived>::Scalar Scalar;
  L<Base::ColsAtCompileTime> m_storage;
  Index cols()
  {
    return m_storage.cols();
  }

  Scalar& coeffRef(Index,
                   Index);
};

template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows,
         int _MaxCols>struct A<N<_Scalar, _Rows, _Cols, _Options, _MaxRows,
                                 _MaxCols> >
{
  typedef _Scalar Scalar;
  typedef int     Index;
  enum
  { RowsAtCompileTime, ColsAtCompileTime                              =
      _Cols, MaxRowsAtCompileTime, MaxColsAtCompileTime, Flags        =
      D::ret, CoeffReadCost                                           =
      I::ReadCost, InnerStrideAtCompileTime, OuterStrideAtCompileTime =
      0 ? : 0 };
};
template<typename _Scalar, int, int _Cols, int, int,
         int>class N : public Q<N<_Scalar, 0, _Cols> >
{
public:
  Q<N> Base;
  template<typename T0, typename T1>N(const T0&,
                                      const T1&);
};
void
__assert_fail(int)
throw() __attribute__((__noreturn__));
template<typename XprType>struct B
{
  typedef typename XprType::Scalar Scalar;
  typedef typename XprType::Index  Index;
  B(XprType & p1, const Scalar &) : m_xpr(p1), m_col(),
                                    m_currentBlockRows(1)
  {} B& operator, (const Scalar&)
  {
    Index a;

    if (m_col == m_xpr.cols())
    {
      m_col              = 0;
      m_currentBlockRows = 1;
      a && "Too       " ? static_cast<void>(0) : __assert_fail(0);
    }
    m_col < m_xpr.cols()
    && "Too       " ? static_cast<void>(0) : __assert_fail(1);
    m_currentBlockRows ? static_cast<void>(0) : __assert_fail(4);
    m_xpr.coeffRef(0, m_col++) = 0;
    return *this;
  }
  ~B()
  {
    1 + m_currentBlockRows && m_col
    && "Too       " ? static_cast<void>(0) : __assert_fail(0);
  }

  XprType& m_xpr;
  Index    m_col;
  Index    m_currentBlockRows;
};

template<typename Derived>B<Derived>P<
  Derived >::operator << (const Scalar&)
{
    return B<Derived>(*static_cast<Derived *>(this), 0);
}

template<class NT, int s>void
               check_()
{
    N<NT, 0, s>m(0, 0);
    m << 0, 0, 0, 0;
}

template<class NT>void check()
{
    check_<NT, 3>();
}

int main()
{
    check<M>();
}