From 048336099ee3c4e29510f140f5505ce2ad79bf55 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 23 Mar 2016 19:42:19 +0100 Subject: [PATCH] re PR c++/70376 (OpenMP taskloop construct fails to instantiate copy constructor(same as Bug 48869)) PR c++/70376 * cp-gimplify.c (genericize_omp_for_stmt): Don't walk OMP_FOR_CLAUSES for OMP_TASKLOOP here. (cp_genericize_r): Handle OMP_TASKLOOP like OMP_TASK, except do call genericize_omp_for_stmt instead of cp_walk_tree on OMP_BODY. * testsuite/libgomp.c++/pr70376.C: New test. From-SVN: r234437 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/cp-gimplify.c | 15 ++++++++++----- libgomp/ChangeLog | 5 +++++ libgomp/testsuite/libgomp.c++/pr70376.C | 20 ++++++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 libgomp/testsuite/libgomp.c++/pr70376.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 499b4568f14..8b3918bc0ca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2016-03-23 Jakub Jelinek + + PR c++/70376 + * cp-gimplify.c (genericize_omp_for_stmt): Don't walk OMP_FOR_CLAUSES + for OMP_TASKLOOP here. + (cp_genericize_r): Handle OMP_TASKLOOP like OMP_TASK, except do call + genericize_omp_for_stmt instead of cp_walk_tree on OMP_BODY. + 2016-03-23 Alexandre Oliva Jason Merrill Jakub Jelinek diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 9bf248216b8..90b3464e5de 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -386,7 +386,8 @@ genericize_omp_for_stmt (tree *stmt_p, int *walk_subtrees, void *data) tree clab = begin_bc_block (bc_continue, locus); cp_walk_tree (&OMP_FOR_BODY (stmt), cp_genericize_r, data, NULL); - cp_walk_tree (&OMP_FOR_CLAUSES (stmt), cp_genericize_r, data, NULL); + if (TREE_CODE (stmt) != OMP_TASKLOOP) + cp_walk_tree (&OMP_FOR_CLAUSES (stmt), cp_genericize_r, data, NULL); cp_walk_tree (&OMP_FOR_INIT (stmt), cp_genericize_r, data, NULL); cp_walk_tree (&OMP_FOR_COND (stmt), cp_genericize_r, data, NULL); cp_walk_tree (&OMP_FOR_INCR (stmt), cp_genericize_r, data, NULL); @@ -1272,7 +1273,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) if (TREE_CODE (d) == VAR_DECL) gcc_assert (CP_DECL_THREAD_LOCAL_P (d) == DECL_THREAD_LOCAL_P (d)); } - else if (TREE_CODE (stmt) == OMP_PARALLEL || TREE_CODE (stmt) == OMP_TASK) + else if (TREE_CODE (stmt) == OMP_PARALLEL + || TREE_CODE (stmt) == OMP_TASK + || TREE_CODE (stmt) == OMP_TASKLOOP) { struct cp_genericize_omp_taskreg omp_ctx; tree c, decl; @@ -1312,7 +1315,10 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) default: break; } - cp_walk_tree (&OMP_BODY (stmt), cp_genericize_r, data, NULL); + if (TREE_CODE (stmt) == OMP_TASKLOOP) + genericize_omp_for_stmt (stmt_p, walk_subtrees, data); + else + cp_walk_tree (&OMP_BODY (stmt), cp_genericize_r, data, NULL); wtd->omp_ctx = omp_ctx.outer; splay_tree_delete (omp_ctx.variables); } @@ -1380,8 +1386,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) genericize_break_stmt (stmt_p); else if (TREE_CODE (stmt) == OMP_FOR || TREE_CODE (stmt) == OMP_SIMD - || TREE_CODE (stmt) == OMP_DISTRIBUTE - || TREE_CODE (stmt) == OMP_TASKLOOP) + || TREE_CODE (stmt) == OMP_DISTRIBUTE) genericize_omp_for_stmt (stmt_p, walk_subtrees, data); else if ((flag_sanitize & (SANITIZE_NULL | SANITIZE_ALIGNMENT | SANITIZE_VPTR)) diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 12d78347d67..cb8c98edabe 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2016-03-23 Jakub Jelinek + + PR c++/70376 + * testsuite/libgomp.c++/pr70376.C: New test. + 2016-03-23 Tom de Vries * testsuite/libgomp.oacc-fortran/reduction-2.f90: Add missing diff --git a/libgomp/testsuite/libgomp.c++/pr70376.C b/libgomp/testsuite/libgomp.c++/pr70376.C new file mode 100644 index 00000000000..595c2cc930c --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/pr70376.C @@ -0,0 +1,20 @@ +// PR c++/70376 +// { dg-do link } + +template +struct A +{ + A() { } + A(const A&) { } + void foo() { } +}; + +int +main () +{ + A a; + #pragma omp taskloop + for (int i = 0; i < 64; i++) + a.foo(); + return 0; +}