Skip to content

Commit

Permalink
PR c++/84520 - ICE with generic lambda in NSDMI.
Browse files Browse the repository at this point in the history
	* lambda.c (lambda_expr_this_capture): Don't look for fake NSDMI
	'this' in a generic lambda instantiation.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258021 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
jason committed Feb 27, 2018
1 parent d7d46e5 commit 9960ad2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
2018-02-26 Jason Merrill <jason@redhat.com>

PR c++/84520 - ICE with generic lambda in NSDMI.
* lambda.c (lambda_expr_this_capture): Don't look for fake NSDMI
'this' in a generic lambda instantiation.

PR c++/84559 - ICE with constexpr VLA.
* constexpr.c (ensure_literal_type_for_constexpr_object): Check
for constexpr variable with VLA type.
Expand Down
5 changes: 4 additions & 1 deletion gcc/cp/lambda.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,11 +758,14 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p)
lambda_stack);

if (LAMBDA_EXPR_EXTRA_SCOPE (tlambda)
&& !COMPLETE_TYPE_P (LAMBDA_EXPR_CLOSURE (tlambda))
&& TREE_CODE (LAMBDA_EXPR_EXTRA_SCOPE (tlambda)) == FIELD_DECL)
{
/* In an NSDMI, we don't have a function to look up the decl in,
but the fake 'this' pointer that we're using for parsing is
in scope_chain. */
in scope_chain. But if the closure is already complete, we're
in an instantiation of a generic lambda, and the fake 'this'
is gone. */
init = scope_chain->x_current_class_ptr;
gcc_checking_assert
(init && (TREE_TYPE (TREE_TYPE (init))
Expand Down
8 changes: 8 additions & 0 deletions gcc/testsuite/g++.dg/cpp1y/lambda-generic-nsdmi1.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// PR c++/84520
// { dg-do compile { target c++14 } }

struct A
{
static void foo(int);
void (*f)(int) = [](auto i) { foo(i); };
};

0 comments on commit 9960ad2

Please sign in to comment.