Skip to content

Commit

Permalink
PR c++/71546 - lambda init-capture with qualified-id.
Browse files Browse the repository at this point in the history
	* parser.c (cp_parser_lambda_introducer): Clear scope after
	each lambda capture.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258043 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
jason committed Feb 27, 2018
1 parent 6e6ee7a commit 5876201
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2018-02-27 Håkon Sandsmark <hsandsmark@gmail.com>

PR c++/71546 - lambda init-capture with qualified-id.
* parser.c (cp_parser_lambda_introducer): Clear scope after
each lambda capture.

2018-02-27 Nathan Sidwell <nathan@acm.org>

PR c++/84426
Expand Down
6 changes: 6 additions & 0 deletions gcc/cp/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -10440,6 +10440,12 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
capture_init_expr,
/*by_reference_p=*/capture_kind == BY_REFERENCE,
explicit_init_p);

/* If there is any qualification still in effect, clear it
now; we will be starting fresh with the next capture. */
parser->scope = NULL_TREE;
parser->qualifying_scope = NULL_TREE;
parser->object_scope = NULL_TREE;
}

cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
Expand Down
10 changes: 10 additions & 0 deletions gcc/testsuite/g++.dg/cpp1y/lambda-init17.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// PR c++/71546
// { dg-do compile { target c++14 } }

namespace n { struct make_shared { }; }

int main()
{
int x1;
[e = n::make_shared (), x1]() {};
}

0 comments on commit 5876201

Please sign in to comment.