aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/torture/pr42450.C
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/g++.dg/torture/pr42450.C
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/torture/pr42450.C')
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/torture/pr42450.C112
1 files changed, 112 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/torture/pr42450.C b/gcc-4.9/gcc/testsuite/g++.dg/torture/pr42450.C
new file mode 100644
index 000000000..f630fa2b7
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/torture/pr42450.C
@@ -0,0 +1,112 @@
+/* { dg-do compile } */
+
+template < typename > class basic_stringstream;
+
+struct basic_string {
+ basic_string();
+};
+
+struct ios_base {
+ virtual ~ios_base();
+};
+
+class ostream:ios_base {};
+class istream:virtual ios_base {};
+
+template < typename > struct basic_iostream:public istream, ostream {
+ ~basic_iostream () {}
+};
+extern template class basic_iostream < char >;
+
+template < typename > struct basic_stringstream:public basic_iostream < char > {
+ basic_string _M_stringbuf;
+ ~basic_stringstream () {}
+};
+extern template class basic_stringstream < char >;
+
+template < typename > struct AnyMatrixBase;
+template < typename, int _Rows, int _Cols, int = _Rows, int = _Cols > class Matrix;
+template < typename > class CwiseNullaryOp;
+
+template < typename Derived > struct MatrixBase:public AnyMatrixBase < Derived > {
+ typedef CwiseNullaryOp < Derived > ConstantReturnType;
+ ConstantReturnType Constant ();
+ template < typename > Derived cast ();
+ static CwiseNullaryOp < Derived > Random (int);
+};
+
+template < typename Derived > struct AnyMatrixBase {
+ Derived derived () {}
+ Derived & derived () const {}
+};
+
+template < typename, int > struct ei_matrix_storage {};
+
+template < typename _Scalar, int, int, int _MaxRows, int _MaxCols > struct Matrix:MatrixBase < Matrix < _Scalar, _MaxRows, _MaxCols > > {
+ typedef MatrixBase < Matrix > Base;
+ ei_matrix_storage < int, _MaxCols > m_storage;
+ Matrix operator= (const Matrix other) {
+ _resize_to_match (other);
+ lazyAssign (other.derived ());
+ }
+ template < typename OtherDerived > Matrix lazyAssign (MatrixBase < OtherDerived > other) {
+ _resize_to_match (other);
+ return Base (other.derived ());
+ }
+ Matrix ();
+ template < typename OtherDerived > Matrix (const MatrixBase < OtherDerived > &other) {
+ *this = other;
+ }
+ template < typename OtherDerived > void _resize_to_match (const MatrixBase < OtherDerived > &) {
+ throw 1;
+ }
+};
+
+template < typename MatrixType > class CwiseNullaryOp:
+public MatrixBase < CwiseNullaryOp < MatrixType > > {};
+
+int f()
+{
+ bool align_cols;
+ if (align_cols) {
+ basic_stringstream<char> sstr;
+ f();
+ }
+}
+
+template < typename > struct AutoDiffScalar;
+template < typename Functor > struct AutoDiffJacobian:Functor {
+ AutoDiffJacobian (Functor);
+ typedef typename Functor::InputType InputType;
+ typedef typename Functor::ValueType ValueType;
+ typedef Matrix < int, Functor::InputsAtCompileTime, 1 > DerivativeType;
+ typedef AutoDiffScalar < DerivativeType > ActiveScalar;
+ typedef Matrix < ActiveScalar, Functor::InputsAtCompileTime, 1 > ActiveInput;
+ void operator () (InputType x, ValueType *) {
+ ActiveInput ax = x.template cast < ActiveScalar > ();
+ }
+};
+
+template < int NX, int NY > struct TestFunc1 {
+ enum {
+ InputsAtCompileTime = NX
+ };
+ typedef Matrix < float, NX, 1 > InputType;
+ typedef Matrix < float, NY, 1 > ValueType;
+ typedef Matrix < float, NY, NX > JacobianType;
+ int inputs ();
+};
+
+template < typename Func > void forward_jacobian (Func f) {
+ typename Func::InputType x = Func::InputType::Random (f.inputs ());
+ typename Func::ValueType y;
+ typename Func::JacobianType jref = jref.Constant ();
+ AutoDiffJacobian < Func > autoj (f);
+ autoj (x, &y);
+}
+
+void test_autodiff_scalar ()
+{
+ forward_jacobian (TestFunc1 < 2, 2 > ());
+ forward_jacobian (TestFunc1 < 3, 2 > ());
+}