aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/cilk-plus/CK/const_spawn.cc
blob: 1ea473f1d57f256479ea2a99252fffd40773ae17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* { dg-options "-fcilkplus" } */
/* { dg-do run { target i?86-*-* x86_64-*-* arm*-*-* } } */
/* { dg-options "-fcilkplus -lcilkrts" { target { i?86-*-* x86_64-*-* arm*-*-* } } } */

class Rectangle
{
  int area_val, h, w;
  public:
    Rectangle (int, int);
    Rectangle (int, int, int);
    ~Rectangle ();
    int area ();
};
Rectangle::~Rectangle ()
{
  h = 0;
  w = 0;
  area_val = 0;
}
Rectangle::Rectangle (int height, int width)
{
  h = height;
  w = width;
  area_val = 0;
}

Rectangle::Rectangle (int height, int width, int area_orig)
{
  h = height;
  w = width;
  area_val = area_orig;
}

int Rectangle::area()
{
  return (area_val += (h*w));
}

/* Spawning constructor.  */
int main1 (void)
{
  Rectangle r = _Cilk_spawn Rectangle (4, 3);
  return r.area();
}
 
/* Spawning constructor 2.  */
int main2 (void)
{
  Rectangle r (_Cilk_spawn Rectangle (4, 3));
  return r.area();
}

/* Spawning copy constructor.  */
int main3 (void)
{
  Rectangle r = _Cilk_spawn Rectangle (4, 3, 2);
  return r.area ();
}

/* Spawning copy constructor 2.  */
int main4 (void)
{
  Rectangle r ( _Cilk_spawn Rectangle (4, 3, 2));
  return r.area();
}

int main (void)
{
  if (main1 () != 12)
    __builtin_abort ();
  if (main2 () != 12)
    __builtin_abort ();
  if (main3 () != 14)
    __builtin_abort ();
  if (main4() != 14)
    __builtin_abort ();
  return 0;
}