| 1 |
/* { dg-do run } */ |
| 2 |
/* Check that classes with virtual member functions works, |
| 3 |
when using it as declared type. */ |
| 4 |
struct base { |
| 5 |
float data [100]; |
| 6 |
|
| 7 |
base() = default; |
| 8 |
virtual ~base() = default; |
| 9 |
}; |
| 10 |
|
| 11 |
struct derived : public base { |
| 12 |
int scalar, array[5]; |
| 13 |
|
| 14 |
derived() = default; |
| 15 |
void do_work () |
| 16 |
{ |
| 17 |
int error = 0; |
| 18 |
#pragma omp target map (tofrom: this[:1], error) |
| 19 |
{ |
| 20 |
if (scalar != 42 || this->array[0] != 123 || array[4] != 555) |
| 21 |
error = 1; |
| 22 |
if (data[0] != 333 || data[99] != -3) |
| 23 |
error = 1; |
| 24 |
this->scalar = 99; |
| 25 |
array[0] = 5; |
| 26 |
array[4] = -4; |
| 27 |
this->data[0] = 11; |
| 28 |
this->data[99] = 99; |
| 29 |
} |
| 30 |
if (error) |
| 31 |
__builtin_abort (); |
| 32 |
if (data[0] != 11 || data[99] != 99) |
| 33 |
__builtin_abort (); |
| 34 |
if (scalar != 99 || array[0] != 5 || array[4] != -4) |
| 35 |
__builtin_abort (); |
| 36 |
} |
| 37 |
}; |
| 38 |
|
| 39 |
int |
| 40 |
main () |
| 41 |
{ |
| 42 |
struct derived x; |
| 43 |
x.data[0] = 333; |
| 44 |
x.data[99] = -3; |
| 45 |
x.scalar = 42; |
| 46 |
x.array[0] = 123; |
| 47 |
x.array[4] = 555; |
| 48 |
x.do_work (); |
| 49 |
return 0; |
| 50 |
} |