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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
My memory is fuzzy about this, but I vaguely remember that e.g. for
parallel/task and similar constructs we need an extra BIND_EXPR, so
      block = begin_omp_parallel ();
      save = cp_parser_begin_omp_structured_block (parser);
...
      cp_parser_end_omp_structured_block (parser, save);
      stmt = finish_omp_parallel (cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL],
                                  block);
or
  block = begin_omp_task ();
  save = cp_parser_begin_omp_structured_block (parser);
...
  cp_parser_end_omp_structured_block (parser, save);
  return finish_omp_task (clauses, block);
etc., exactly to make sure local variables stay within that body and even
temporaries are created there if needed.
begin_omp_parallel is
  keep_next_level (true);
  return begin_omp_structured_block ();
and the keep_next_level (true); in there ensures the BIND_EXPR is not optimized
away and stays around no matter what.
Now, for OMP_FOR we clearly don't need that, but supposedly for OMP_TASKLOOP or
for
combined OMP_DISTRIBUTE with OMP_FOR or for OMP_LOOP (at least in some cases)
we do.

Reply via email to