Hi!

If we call omp_add_variable, following omp_notice_variable will already find it
on that construct and not go through outer constructs, the following patch 
fixes that.
Note, this still doesn't follow OpenMP 5.0 semantics on target combined with 
other
constructs with reduction/lastprivate/linear clauses, will handle that for 
GCC11.

Without this patch, the patch I'll post next breaks
c-c++-common/gomp/loop-5.c testcase.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2020-02-06  Jakub Jelinek  <ja...@redhat.com>

        PR libgomp/93515
        * gimplify.c (gimplify_scan_omp_clauses) <do_notice>: If adding
        shared clause, call omp_notice_variable on outer context if any.

--- gcc/gimplify.c.jj   2020-01-17 12:42:46.000000000 +0100
+++ gcc/gimplify.c      2020-02-05 15:25:25.316658638 +0100
@@ -9464,9 +9464,13 @@ gimplify_scan_omp_clauses (tree *list_p,
                                  == POINTER_TYPE))))
                    omp_firstprivatize_variable (outer_ctx, decl);
                  else
-                   omp_add_variable (outer_ctx, decl,
-                                     GOVD_SEEN | GOVD_SHARED);
-                 omp_notice_variable (outer_ctx, decl, true);
+                   {
+                     omp_add_variable (outer_ctx, decl,
+                                       GOVD_SEEN | GOVD_SHARED);
+                     if (outer_ctx->outer_context)
+                       omp_notice_variable (outer_ctx->outer_context, decl,
+                                            true);
+                   }
                }
            }
          if (outer_ctx)


        Jakub

Reply via email to