Debian Codegraph @

gcc/testsuite/g++.dg/torture/pr45393.C

raw
1 // { dg-do compile }
2
3 class FloatPoint;
4 class Path {
5 public:
6 ~Path();
7 void moveTo(const FloatPoint&);
8 static void createEllipse(const FloatPoint& center, float rx, float ry);
9 };
10 extern "C" {
11 extern float cosf (float);
12 extern float sinf (float);
13 }
14 const float piFloat = static_cast<float>(3.14159265358979323846);
15 class FloatPoint {
16 public:
17 FloatPoint(float x, float y) : m_x(x), m_y(y) { }
18 float x() const;
19 float y() const;
20 float m_x, m_y;
21 };
22 void Path::createEllipse(const FloatPoint& center, float rx, float ry)
23 {
24 float cx = center.x();
25 float cy = center.y();
26 Path path;
27 float x = cx;
28 float y = cy;
29 unsigned step = 0, num = 100;
30 while (1) {
31 float angle = static_cast<float>(step) / num * 2.0f * piFloat;
32 x = cx + cosf(angle) * rx;
33 y = cy + sinf(angle) * ry;
34 step++;
35 if (step == 1)
36 path.moveTo(FloatPoint(x, y));
37 }
38 }