]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/g++.dg/cilk-plus/CK/const_spawn.cc
[Patch AArch64] Fixup floating point division with -march=armv8-a+nosimd
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / cilk-plus / CK / const_spawn.cc
1 /* { dg-do run } */
2 /* { dg-require-effective-target cilkplus_runtime } */
3 /* { dg-options "-fcilkplus" } */
4
5 class Rectangle
6 {
7 int area_val, h, w;
8 public:
9 Rectangle (int, int);
10 Rectangle (int, int, int);
11 ~Rectangle ();
12 int area ();
13 };
14 Rectangle::~Rectangle ()
15 {
16 h = 0;
17 w = 0;
18 area_val = 0;
19 }
20 Rectangle::Rectangle (int height, int width)
21 {
22 h = height;
23 w = width;
24 area_val = 0;
25 }
26
27 Rectangle::Rectangle (int height, int width, int area_orig)
28 {
29 h = height;
30 w = width;
31 area_val = area_orig;
32 }
33
34 int Rectangle::area()
35 {
36 return (area_val += (h*w));
37 }
38
39 /* Spawning constructor. */
40 int main1 (void)
41 {
42 Rectangle r = _Cilk_spawn Rectangle (4, 3);
43 return r.area();
44 }
45
46 /* Spawning constructor 2. */
47 int main2 (void)
48 {
49 Rectangle r (_Cilk_spawn Rectangle (4, 3));
50 return r.area();
51 }
52
53 /* Spawning copy constructor. */
54 int main3 (void)
55 {
56 Rectangle r = _Cilk_spawn Rectangle (4, 3, 2);
57 return r.area ();
58 }
59
60 /* Spawning copy constructor 2. */
61 int main4 (void)
62 {
63 Rectangle r ( _Cilk_spawn Rectangle (4, 3, 2));
64 return r.area();
65 }
66
67 int main (void)
68 {
69 if (main1 () != 12)
70 __builtin_abort ();
71 if (main2 () != 12)
72 __builtin_abort ();
73 if (main3 () != 14)
74 __builtin_abort ();
75 if (main4() != 14)
76 __builtin_abort ();
77 return 0;
78 }