From: Jakub Jelinek Date: Tue, 30 May 2017 07:44:11 +0000 (+0200) Subject: backport: re PR c++/77739 (internal compiler error: in create_tmp_var, at gimple... X-Git-Tag: releases/gcc-5.5.0~284 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abd8d9e75dd7fb34a653592480f3a030113883d0;p=thirdparty%2Fgcc.git backport: re PR c++/77739 (internal compiler error: in create_tmp_var, at gimple-expr.c:524) Backported from mainline 2016-11-23 Jakub Jelinek PR c++/77739 * cp-gimplify.c (cp_gimplify_tree) : Pass false as handle_invisiref_parm_p to cp_genericize_tree. (struct cp_genericize_data): Add handle_invisiref_parm_p field. (cp_genericize_r): Don't wrap is_invisiref_parm into references if !wtd->handle_invisiref_parm_p. (cp_genericize_tree): Add handle_invisiref_parm_p argument, set wtd.handle_invisiref_parm_p to it. (cp_genericize): Pass true as handle_invisiref_parm_p to cp_genericize_tree. Formatting fix. * g++.dg/cpp1y/pr77739.C: New test. From-SVN: r248627 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 98bb4fc0b0ab..75be7eae019c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,19 @@ 2017-05-30 Jakub Jelinek Backported from mainline + 2016-11-23 Jakub Jelinek + + PR c++/77739 + * cp-gimplify.c (cp_gimplify_tree) : Pass + false as handle_invisiref_parm_p to cp_genericize_tree. + (struct cp_genericize_data): Add handle_invisiref_parm_p field. + (cp_genericize_r): Don't wrap is_invisiref_parm into references + if !wtd->handle_invisiref_parm_p. + (cp_genericize_tree): Add handle_invisiref_parm_p argument, + set wtd.handle_invisiref_parm_p to it. + (cp_genericize): Pass true as handle_invisiref_parm_p to + cp_genericize_tree. Formatting fix. + 2016-11-18 Jakub Jelinek PR c++/77285 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index b948c536d3f0..65f7ef1b1588 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -59,7 +59,7 @@ along with GCC; see the file COPYING3. If not see /* Forward declarations. */ static tree cp_genericize_r (tree *, int *, void *); -static void cp_genericize_tree (tree*); +static void cp_genericize_tree (tree*, bool); /* Local declarations. */ @@ -592,7 +592,7 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) init, VEC_INIT_EXPR_VALUE_INIT (*expr_p), from_array, tf_warning_or_error); - cp_genericize_tree (expr_p); + cp_genericize_tree (expr_p, false); ret = GS_OK; input_location = loc; } @@ -906,6 +906,7 @@ struct cp_genericize_data vec bind_expr_stack; struct cp_genericize_omp_taskreg *omp_ctx; bool no_sanitize_p; + bool handle_invisiref_parm_p; }; /* Perform any pre-gimplification lowering of C++ front end trees to @@ -926,7 +927,8 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) && omp_var_to_track (stmt)) omp_cxx_notice_variable (wtd->omp_ctx, stmt); - if (is_invisiref_parm (stmt) + if (wtd->handle_invisiref_parm_p + && is_invisiref_parm (stmt) /* Don't dereference parms in a thunk, pass the references through. */ && !(DECL_THUNK_P (current_function_decl) && TREE_CODE (stmt) == PARM_DECL)) @@ -1279,7 +1281,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) /* Lower C++ front end trees to GENERIC in T_P. */ static void -cp_genericize_tree (tree* t_p) +cp_genericize_tree (tree* t_p, bool handle_invisiref_parm_p) { struct cp_genericize_data wtd; @@ -1287,6 +1289,7 @@ cp_genericize_tree (tree* t_p) wtd.bind_expr_stack.create (0); wtd.omp_ctx = NULL; wtd.no_sanitize_p = false; + wtd.handle_invisiref_parm_p = handle_invisiref_parm_p; cp_walk_tree (t_p, cp_genericize_r, &wtd, NULL); delete wtd.p_set; wtd.bind_expr_stack.release (); @@ -1399,12 +1402,12 @@ cp_genericize (tree fndecl) /* Expand all the array notations here. */ if (flag_cilkplus && contains_array_notation_expr (DECL_SAVED_TREE (fndecl))) - DECL_SAVED_TREE (fndecl) = - expand_array_notation_exprs (DECL_SAVED_TREE (fndecl)); + DECL_SAVED_TREE (fndecl) + = expand_array_notation_exprs (DECL_SAVED_TREE (fndecl)); /* We do want to see every occurrence of the parms, so we can't just use walk_tree's hash functionality. */ - cp_genericize_tree (&DECL_SAVED_TREE (fndecl)); + cp_genericize_tree (&DECL_SAVED_TREE (fndecl), true); if (flag_sanitize & SANITIZE_RETURN && do_ubsan_in_current_function ()) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2eb127db2f5e..968c228b150a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2017-05-30 Jakub Jelinek Backported from mainline + 2016-11-23 Jakub Jelinek + + PR c++/77739 + * g++.dg/cpp1y/pr77739.C: New test. + 2016-11-22 Jakub Jelinek PR middle-end/78416 diff --git a/gcc/testsuite/g++.dg/cpp1y/pr77739.C b/gcc/testsuite/g++.dg/cpp1y/pr77739.C new file mode 100644 index 000000000000..96183305a7d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr77739.C @@ -0,0 +1,15 @@ +// PR c++/77739 +// { dg-do compile { target c++14 } } + +struct A { + A(); + A(const A &); +}; +struct B { + B(); + template auto g(Args &&... p1) { + return [=] { f(p1...); }; + } + void f(A, const char *); +}; +B::B() { g(A(), ""); }