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

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Actually, I'm afraid the above is not sufficient.  I think
template <typename T>
struct S {
  T x;
  int y;
};

void
foo (int x)
{
  auto b = [&] { return x; };
  S <decltype (b)> c = { b, 42 };
  #pragma omp target
  if (c.x () != 42)
    __builtin_abort ();
}

int
main ()
{
  foo (42);
}
is a valid testcase, so we can't just record in lambda_objects_accessed
vars/parms/results, but on the other side, remembering there random expressions
which never can't be mapped seems wrong too.  If it is a simple chain of
COMPONENT_REFs/ARRAY_REFs (one can also do S <decltype (b)> d[2] = { { b, 42 },
{ b, 43 } }; and use
  d[i].x ();
etc.), one can check if the the get_base_address of it is a local_decl or not.
What about pointers?  One can have above auto *p = &c; etc. before the target
region.

Reply via email to