diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/torture/pr39002.C | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
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.
Diffstat (limited to 'gcc/testsuite/g++.dg/torture/pr39002.C')
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr39002.C | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/torture/pr39002.C b/gcc/testsuite/g++.dg/torture/pr39002.C new file mode 100644 index 000000000..534d91dfa --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr39002.C @@ -0,0 +1,88 @@ +// PR target/39002 +// { dg-do run } + +struct S +{ + double x; + double y; + double z; +}; + +double foo (S *, S *); +void bar (S *, S *, S *, double &, double &, double &); + +double +foo (S *a1, S *a2) +{ + return __builtin_sqrt ((a1->x - a2->x) * (a1->x - a2->x) + + (a1->y - a2->y) * (a1->y - a2->y) + + (a1->z - a2->z) * (a1->z - a2->z)); +} + +void +bar (S *p, S *q, S *r, double &x, double &y, double &z) +{ + if (foo (p, q) == 0.0) + { + x = r->x; + y = r->y; + z = r->z; + return; + } + if (foo (p, r) == 0.0) + { + x = r->x; + y = r->y; + z = r->z; + return; + } + if (foo (q, r) == 0.0) + { + x = r->x; + y = r->y; + z = r->z; + return; + } + + double a1, b1, c1, d1, e1; + double dx, dy, dz, dw, dv; + + a1 = q->x - p->x; + b1 = q->y - p->y; + c1 = q->z - p->z; + e1 = __builtin_sqrt (a1 * a1 + b1 * b1 + c1 * c1); + a1 = a1 / e1; + b1 = b1 / e1; + c1 = c1 / e1; + dx = p->x - r->x; + dy = p->y - r->y; + dz = p->z - r->z; + dw = dx * dx + dy * dy + dz * dz; + dv = 2.0 * dx * a1 + 2.0 * dy * b1 + 2.0 * dz * c1; + d1 = -dv / 2.0; + x = p->x + (a1 * d1); + y = p->y + (b1 * d1); + z = p->z + (c1 * d1); + return; +} + +int +main (void) +{ + S a, b, c, d, *p, *q, *r; + + p = &a; + q = &b; + r = &c; + a.x = 0.0; + a.y = 0.0; + a.z = 0.0; + b.x = 1.0; + b.y = 0.0; + b.z = 0.0; + c.x = 0.0; + c.y = 1.0; + c.z = 0.0; + bar (p, q, r, d.x, d.y, d.z); + return 0; +} |