aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/target-this-2.C
blob: 8119be8c2c5df9ddcbf9f47a0d539f435900214a (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

// We use 'auto' without a function return type, so specify dialect here
// { dg-additional-options "-std=c++14" }

extern "C" void abort ();

struct T
{
  int x, y;

  auto sum_func (int n)
  {
    auto fn = [=](int m) -> int
      {
	int v;
	v = (x + y) * n + m;
	return v;
      };
    return fn;
  }

  auto sum_func_offload (int n)
  {
    auto fn = [=](int m) -> int
      {
	int v;
	#pragma omp target map(from:v)
	v = (x + y) * n + m;
	return v;
      };
    return fn;
  }

};

int main (void)
{
  T a = { 1, 2 };

  auto s1 = a.sum_func (3);
  auto s2 = a.sum_func_offload (3);

  if (s1 (1) != s2 (1))
    abort ();

  return 0;
}