aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/target-virtual-1.C
blob: a6ac30e7cf0a63c1d6d50c935da3835a0739bf1d (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
/* { dg-do run } */
/* Check that classes with virtual member functions works,
   when using it as declared type. */
struct base {
    float data [100];

    base() = default;
    virtual ~base() = default;
};

struct derived : public base {
    int scalar, array[5];

    derived() = default;
    void do_work ()
    {
      int error = 0;
      #pragma omp target map (tofrom: this[:1], error)
      {
	if (scalar != 42 || this->array[0] != 123 || array[4] != 555)
	  error = 1;
	if (data[0] != 333 || data[99] != -3)
	  error = 1;
	this->scalar = 99;
	array[0] = 5;
	array[4] = -4;
	this->data[0] = 11;
	this->data[99] = 99;
      }
      if (error)
	__builtin_abort ();
      if (data[0] != 11 || data[99] != 99)
	__builtin_abort ();
      if (scalar != 99 || array[0] != 5 || array[4] != -4)
	__builtin_abort ();
    }   
};

int
main ()
{
  struct derived x;
  x.data[0] = 333;
  x.data[99] = -3;
  x.scalar = 42;
  x.array[0] = 123;
  x.array[4] = 555;
  x.do_work ();
  return 0;
}