From ee78cbaa8956684189f8fe3ca2b4fcac7d48df91 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 21 Jul 2016 09:02:04 +0200 Subject: [PATCH] re PR libgomp/71941 (ICE with OpenMP tasks and queue) PR c++/71941 * cp-gimplify.c (cp_genericize): For nested cp_genericize calls save/restore bc_label array. * g++.dg/gomp/pr71941.C: New test. From-SVN: r238579 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cp-gimplify.c | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/gomp/pr71941.C | 22 ++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 gcc/testsuite/g++.dg/gomp/pr71941.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2e8877faef9..30a0b44c121 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-07-21 Jakub Jelinek + + PR c++/71941 + * cp-gimplify.c (cp_genericize): For nested cp_genericize calls + save/restore bc_label array. + 2016-07-21 Jason Merrill PR c++/70781 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index ee28ba5738f..59953a6ee04 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1632,6 +1632,13 @@ cp_genericize (tree fndecl) if (DECL_CLONED_FUNCTION_P (fndecl)) return; + /* Allow cp_genericize calls to be nested. */ + tree save_bc_label[2]; + save_bc_label[bc_break] = bc_label[bc_break]; + save_bc_label[bc_continue] = bc_label[bc_continue]; + bc_label[bc_break] = NULL_TREE; + bc_label[bc_continue] = NULL_TREE; + /* Expand all the array notations here. */ if (flag_cilkplus && contains_array_notation_expr (DECL_SAVED_TREE (fndecl))) @@ -1651,6 +1658,8 @@ cp_genericize (tree fndecl) gcc_assert (bc_label[bc_break] == NULL); gcc_assert (bc_label[bc_continue] == NULL); + bc_label[bc_break] = save_bc_label[bc_break]; + bc_label[bc_continue] = save_bc_label[bc_continue]; } /* Build code to apply FN to each member of ARG1 and ARG2. FN may be diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 004cb5881f5..48f7bafda0f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-21 Jakub Jelinek + + PR c++/71941 + * g++.dg/gomp/pr71941.C: New test. + 2016-07-20 David Malcolm PR c/70339 diff --git a/gcc/testsuite/g++.dg/gomp/pr71941.C b/gcc/testsuite/g++.dg/gomp/pr71941.C new file mode 100644 index 00000000000..ffa53d03e60 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr71941.C @@ -0,0 +1,22 @@ +// PR c++/71941 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct A { A (); A (A &); ~A (); }; + +template +struct B +{ + struct C { A a; C () : a () {} }; + C c; + void foo (); +}; + +void +bar () +{ + B<0> b; +#pragma omp task + for (int i = 0; i < 2; i++) + b.foo (); +} -- 2.30.2