From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/g++.dg/debug/pr46240.cc | 172 ++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 gcc/testsuite/g++.dg/debug/pr46240.cc (limited to 'gcc/testsuite/g++.dg/debug/pr46240.cc') diff --git a/gcc/testsuite/g++.dg/debug/pr46240.cc b/gcc/testsuite/g++.dg/debug/pr46240.cc new file mode 100644 index 000000000..c12a6988a --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr46240.cc @@ -0,0 +1,172 @@ +// { dg-do compile } +// { dg-options "-O3 -g" } + +template +T &max (T &a, T &b) +{ + if (a < b) return b; else return a; +} +int foo (double); +struct S +{ + struct T + { + int dims, count; + T (int, int) : dims (), count () {} + }; + T *rep; + S () {} + S (int r, int c) : rep (new T (r, c)) {} + ~S () { delete rep; } +}; +template +struct U +{ + static T epsilon () throw (); +}; +template +struct V +{ + struct W + { + T * data; + int count; + W (int n) : data (new T[n]), count () {} + }; + V::W *rep; + S dimensions; + int slice_len; + V (S s) : rep (new V ::W (get_size (s))) {} + int capacity () { return slice_len; } + int get_size (S); +}; +template +struct Z : public V +{ + Z () : V (S (0, 0)) {} + Z (int r, int c) : V (S (r, c)) {} +}; +template +struct A : public Z +{ + A () : Z () {} + A (int n, int m) : Z (n, m) {} +}; +template +struct B : public V +{ +}; +struct C : public A +{ + C () : A () {} + C (int r, int c) : A (r, c) {} +}; +struct D : public B +{ +}; +template +struct E +{ +}; +template +struct G : public E +{ +}; +struct H : public G +{ +}; +template +struct I +{ + R scl, sum; + void accum (R val) + { + R t = __builtin_fabs (val); + if (scl == t) + sum += 1; + } + operator R () { __builtin_sqrt (sum); return R (); } +}; +template +struct J +{ + template < class U > void accum (U val) {} + operator R () { return R (); } +}; +template +struct K +{ + R max; + template void accum (U val) + { + double z = __builtin_fabs (val); + max = ::max (max, z); + } + operator R () { return max; } +}; +template +struct L +{ + unsigned num; + template void accum (U) {} + operator R () { return num; } +}; +template +void bar (V &v, R &res, S acc) +{ + for (int i = 0; i < v.capacity (); i++) + acc.accum ((i)); + res = acc; +} +template +void bar (B &v, R) +{ + R res; + bar (v, res, I ()); +} +template +R bar (A &v, R p) +{ + R res; + if (p == 2) + bar (v, res, I ()); + else if (p == 1) + bar (v, res, J ()); + else if (p == sizeof (float) ? (p) : foo (p)) + { + if (p > 0) + bar (v, res, K ()); + } + else if (p == 0) + bar (v, res, L ()); + return res; +} +template +void +baz (CT m, R p, R tol, int maxiter, VectorT) +{ + VectorT y (0, 0), z (0, 1); + R q = 0; + R gamma = 0, gamma1 = 0; + gamma = bar (y, p); + (void) (bar (z, q) <= (gamma1 <= gamma)); +} +int a = 100; +template +void +test (CT m, R p, VectorT) +{ + VectorT x; + R sqrteps (U ::epsilon ()); + baz (m, p, sqrteps, a, x); +} +void +fn (D x, double p) +{ + bar (x, p); +} +void +fn (H x, double p) +{ + test (x, p, C ()); +} -- cgit v1.2.3