Commit 86e95f35 by Pádraig Brady Committed by Nathan Sidwell

[PR c++/87185] ICE in prune-lambdas

https://gcc.gnu.org/ml/gcc-patches/2018-09/msg00249.html
	cp/
	PR c++/87185
	* lambda.c (prune_lambda_captures): Protect against const_vars.get
	returning NULL.
	testsuite/
	PR c++/87185
	* g++.dg/pr87185.C: New.

From-SVN: r264118
parent 888157af
2018-09-05 Pádraig Brady p@draigbrady.com
PR c++/87185
* lambda.c (prune_lambda_captures): Protect against const_vars.get
returning NULL.
2018-09-04 Marek Polacek <polacek@redhat.com> 2018-09-04 Marek Polacek <polacek@redhat.com>
* cp-tree.h (treat_lvalue_as_rvalue_p): Declare. * cp-tree.h (treat_lvalue_as_rvalue_p): Declare.
......
...@@ -1519,8 +1519,8 @@ prune_lambda_captures (tree body) ...@@ -1519,8 +1519,8 @@ prune_lambda_captures (tree body)
tree cap = *capp; tree cap = *capp;
if (tree var = var_to_maybe_prune (cap)) if (tree var = var_to_maybe_prune (cap))
{ {
tree *use = *const_vars.get (var); tree **use = const_vars.get (var);
if (TREE_CODE (*use) == DECL_EXPR) if (use && TREE_CODE (**use) == DECL_EXPR)
{ {
/* All uses of this capture were folded away, leaving only the /* All uses of this capture were folded away, leaving only the
proxy declaration. */ proxy declaration. */
...@@ -1535,7 +1535,7 @@ prune_lambda_captures (tree body) ...@@ -1535,7 +1535,7 @@ prune_lambda_captures (tree body)
*fieldp = DECL_CHAIN (*fieldp); *fieldp = DECL_CHAIN (*fieldp);
/* And remove the capture proxy declaration. */ /* And remove the capture proxy declaration. */
*use = void_node; **use = void_node;
continue; continue;
} }
} }
......
2018-09-05 Pádraig Brady p@draigbrady.com
PR c++/87185
* g++.dg/pr87185.C: New.
2018-09-05 Martin Liska <mliska@suse.cz> 2018-09-05 Martin Liska <mliska@suse.cz>
PR testsuite/87216 PR testsuite/87216
......
// PR c++/87185
// { dg-do compile { target c++11 } }
void f() { const int i=0; [&]() noexcept {i;}; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment