OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [torture/] [pr40321.C] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
/* { dg-do compile } */
2
 
3
struct VectorD2
4
{
5
  VectorD2() : x(0), y(0) { }
6
  VectorD2(int _x, int _y) : x(_x), y(_y) { }
7
  int x, y;
8
  int GetLength2() const { return x*x + y*y; };
9
  VectorD2 operator+(const VectorD2 vec) const {
10
      return VectorD2(x+vec.x,y+vec.y);
11
  }
12
};
13
struct Shape
14
{
15
  enum Type { ST_RECT, ST_CIRCLE } type;
16
  VectorD2 pos;
17
  VectorD2 radius;
18
  bool CollisionWith(const Shape& s) const;
19
};
20
bool Shape::CollisionWith(const Shape& s) const
21
{
22
  if(type == ST_CIRCLE && s.type == ST_RECT)
23
    return s.CollisionWith(*this);
24
  return (pos + s.pos).GetLength2() < (radius + s.radius).GetLength2();
25
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.