annotate gcc/testsuite/g++.dg/torture/pr40321.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* { dg-do compile } */
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 struct VectorD2
kono
parents:
diff changeset
4 {
kono
parents:
diff changeset
5 VectorD2() : x(0), y(0) { }
kono
parents:
diff changeset
6 VectorD2(int _x, int _y) : x(_x), y(_y) { }
kono
parents:
diff changeset
7 int x, y;
kono
parents:
diff changeset
8 int GetLength2() const { return x*x + y*y; };
kono
parents:
diff changeset
9 VectorD2 operator+(const VectorD2 vec) const {
kono
parents:
diff changeset
10 return VectorD2(x+vec.x,y+vec.y);
kono
parents:
diff changeset
11 }
kono
parents:
diff changeset
12 };
kono
parents:
diff changeset
13 struct Shape
kono
parents:
diff changeset
14 {
kono
parents:
diff changeset
15 enum Type { ST_RECT, ST_CIRCLE } type;
kono
parents:
diff changeset
16 VectorD2 pos;
kono
parents:
diff changeset
17 VectorD2 radius;
kono
parents:
diff changeset
18 bool CollisionWith(const Shape& s) const;
kono
parents:
diff changeset
19 };
kono
parents:
diff changeset
20 bool Shape::CollisionWith(const Shape& s) const
kono
parents:
diff changeset
21 {
kono
parents:
diff changeset
22 if(type == ST_CIRCLE && s.type == ST_RECT)
kono
parents:
diff changeset
23 return s.CollisionWith(*this);
kono
parents:
diff changeset
24 return (pos + s.pos).GetLength2() < (radius + s.radius).GetLength2();
kono
parents:
diff changeset
25 }