1// PR target/70098 2// { dg-do compile } 3// { dg-options -O2 } 4// { dg-require-effective-target c++11 } 5// { dg-xfail-if "PR70098" { lp64 && powerpc64_no_dm } } 6// { dg-prune-output ".*internal compiler error.*" } 7 8template < typename > struct traits; 9template < typename, int _Rows, int _Cols, int = 0, int = _Rows, 10 int = _Cols > class Matrix; 11template < typename > class G; 12template < typename Derived > struct A { 13 typedef G < Derived > type; 14}; 15 16template < typename Derived > class C { 17public: 18 enum { RowsAtCompileTime = 19 traits < Derived >::RowsAtCompileTime } static Zero; 20}; 21 22template < typename Derived > class G:public C < Derived > { 23}; 24 25template < int _Rows > class D { 26public: 27 long rows() { 28 return _Rows; 29 } 30}; 31 32template < typename Derived > class PlainObjectBase:public A < Derived >::type { 33 typedef typename A < Derived >::type Base; 34 D < Base::RowsAtCompileTime > m_storage; 35 36public: 37 long rows() { 38 return m_storage.rows(); 39 } 40}; 41 42int fn1(); 43 44struct B { 45 static long run(long x, long) { 46 int offset(fn1()); 47 return x + offset; 48}}; 49 50long fn2(int x) 51{ 52 return B::run(x, 0); 53} 54 55template < typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, 56 int _MaxCols > 57 struct traits <Matrix < _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols >> { 58 enum { RowsAtCompileTime = _Rows }; 59}; 60 61template < typename, int, int, int, int _MaxRows, int _MaxCols > 62 class Matrix:public PlainObjectBase < Matrix < double, _MaxRows, 63 _MaxCols >> { 64public: 65 template < typename OtherDerived > Matrix(OtherDerived); 66}; 67 68struct F { 69 static Matrix < double, 2, 2 > run(long size) { 70 Matrix < double, 2, 2 > diag = Matrix < double, 2, 2 >::Zero; 71 long i = 0; 72 while (i < size) { 73 long randomInt = fn2(-1); 74 if (randomInt == 0) 75 ++i; 76 else { 77 double alpha(randomInt); 78 diag = alpha; 79 i = 2; 80 } 81 } 82 83 return diag; 84 } 85}; 86 87void fn3(Matrix < double, 2, 2 > m) 88{ 89 long size = m.rows(); 90 F::run(size); 91} 92