https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127559

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Another testcase
template <typename T>
struct S {
  T x;
  int y;
};

template <typename T>
T
bar (T x)
{
  return x;
}

void
foo (int x, int y)
{
  auto b = [&] { return x; };
  S <decltype (b)> c = { b, 42 };
  S <decltype (b)> d[2] = { { b, 42 }, { c, 42 } };
  auto *p = &d[1];
  #pragma omp target
  if (c.x () != 42 || d[y].x () != 42 || foo (p)->x () != 42)
    __builtin_abort ();
}

int
main ()
{
  foo (42, 0);
}

I'd think all of this finish_omp_target_clauses* is premature, it should have
been done with a target hook during gimplification IMHO.
Only then we know exactly, this is mapped, this is not.  And for what is
mapped, we simply look whether it is a lambda, or if it is a structure mapping
with default mapper or array thereof, look also at the subobjects thereof
recursively, and handle lambdas the way it should.

Now, I guess having the lambdas as subobjects isn't that common, so for some
time we could live just with a partial fix in the FE.

Reply via email to