+2020-03-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/93931
+ * parser.c (cp_parser_omp_var_list_no_open): Call process_outer_var_ref
+ on outer_automatic_var_p decls.
+ * cp-gimplify.c (cxx_omp_disregard_value_expr): Return true also for
+ capture proxy decls.
+
2020-03-18 Nathan Sidwell <nathan@acm.org>
PR c++/94147 - mangling of lambdas assigned to globals
bool
cxx_omp_disregard_value_expr (tree decl, bool shared)
{
- return !shared
- && VAR_P (decl)
- && DECL_HAS_VALUE_EXPR_P (decl)
- && DECL_ARTIFICIAL (decl)
- && DECL_LANG_SPECIFIC (decl)
- && DECL_OMP_PRIVATIZED_MEMBER (decl);
+ if (shared)
+ return false;
+ if (VAR_P (decl)
+ && DECL_HAS_VALUE_EXPR_P (decl)
+ && DECL_ARTIFICIAL (decl)
+ && DECL_LANG_SPECIFIC (decl)
+ && DECL_OMP_PRIVATIZED_MEMBER (decl))
+ return true;
+ if (VAR_P (decl) && DECL_CONTEXT (decl) && is_capture_proxy (decl))
+ return true;
+ return false;
}
/* Fold expression X which is used as an rvalue if RVAL is true. */
token->location);
}
}
+ if (outer_automatic_var_p (decl))
+ decl = process_outer_var_ref (decl, tf_warning_or_error);
if (decl == error_mark_node)
;
else if (kind != 0)
+2020-03-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/93931
+ * testsuite/libgomp.c++/pr93931.C: New test.
+
2020-03-19 Tobias Burnus <tobias@codesourcery.com>
* testsuite/libgomp.c-c++-common/function-not-offloaded.c: Add
--- /dev/null
+// PR c++/93931
+// { dg-do run }
+// { dg-options "-O2 -std=c++14" }
+
+extern "C" void abort ();
+
+void
+sink (int &x)
+{
+ int *volatile p;
+ p = &x;
+ (*p)++;
+}
+
+int
+foo ()
+{
+ int r = 0;
+ [&r] () {
+#pragma omp parallel for reduction(+ : r)
+ for (int i = 0; i < 1024; ++i)
+ r += i;
+ } ();
+ return r;
+}
+
+int
+bar ()
+{
+ int l = 0;
+ [&l] () {
+#pragma omp parallel for lastprivate (l)
+ for (int i = 0; i < 1024; ++i)
+ l = i;
+ } ();
+ return l;
+}
+
+void
+baz ()
+{
+ int f = 18;
+ [&f] () {
+#pragma omp parallel for firstprivate (f)
+ for (int i = 0; i < 1024; ++i)
+ {
+ sink (f);
+ f += 3;
+ sink (f);
+ if (f != 23)
+ abort ();
+ sink (f);
+ f -= 7;
+ sink (f);
+ }
+ } ();
+ if (f != 18)
+ abort ();
+}
+
+int
+qux ()
+{
+ int r = 0;
+ [&] () {
+#pragma omp parallel for reduction(+ : r)
+ for (int i = 0; i < 1024; ++i)
+ r += i;
+ } ();
+ return r;
+}
+
+int
+corge ()
+{
+ int l = 0;
+ [&] () {
+#pragma omp parallel for lastprivate (l)
+ for (int i = 0; i < 1024; ++i)
+ l = i;
+ } ();
+ return l;
+}
+
+void
+garply ()
+{
+ int f = 18;
+ [&] () {
+#pragma omp parallel for firstprivate (f)
+ for (int i = 0; i < 1024; ++i)
+ {
+ sink (f);
+ f += 3;
+ sink (f);
+ if (f != 23)
+ abort ();
+ sink (f);
+ f -= 7;
+ sink (f);
+ }
+ } ();
+ if (f != 18)
+ abort ();
+}
+
+int
+main ()
+{
+ if (foo () != 1024 * 1023 / 2)
+ abort ();
+ if (bar () != 1023)
+ abort ();
+ baz ();
+ if (qux () != 1024 * 1023 / 2)
+ abort ();
+ if (corge () != 1023)
+ abort ();
+ garply ();
+}