From dda0944cd51484658f2e1d3ec39800fd6709b6af Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 20 Feb 2018 09:20:37 +0100 Subject: [PATCH] re PR c++/84455 (ICE in build_call_a at gcc/cp/call.c:389 during error reporting) PR c++/84455 * pt.c (tsubst_lambda_expr): If not nested, increment temporarily function_depth to avoid GC during finish_lambda_function. * g++.dg/cpp0x/lambda/lambda-ice26.C: New test. From-SVN: r257838 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice26.C | 5 +++++ 4 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice26.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 000e72f2286..726c0951499 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-02-20 Jakub Jelinek + + PR c++/84455 + * pt.c (tsubst_lambda_expr): If not nested, increment temporarily + function_depth to avoid GC during finish_lambda_function. + 2018-02-19 Jason Merrill PR c++/84429 - ICE capturing VLA. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 89790717eca..bc03f0e818e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17070,6 +17070,10 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) bool nested = cfun; if (nested) push_function_context (); + else + /* Still increment function_depth so that we don't GC in the + middle of an expression. */ + ++function_depth; local_specialization_stack s (lss_copy); @@ -17084,6 +17088,8 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (nested) pop_function_context (); + else + --function_depth; /* The capture list was built up in reverse order; fix that now. */ LAMBDA_EXPR_CAPTURE_LIST (r) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 531d29ad4cf..9c1391e6120 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-20 Jakub Jelinek + + PR c++/84455 + * g++.dg/cpp0x/lambda/lambda-ice26.C: New test. + 2018-02-19 Paul Thomas PR fortran/83344 diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice26.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice26.C new file mode 100644 index 00000000000..7544b270256 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice26.C @@ -0,0 +1,5 @@ +// PR c++/84455 +// { dg-do compile { target c++11 } } +// { dg-options "--param ggc-min-heapsize=0" } + +#include "lambda-ice14.C" -- 2.30.2