From 76bd270a7df7dbf5a02046072947802365bb67f6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?H=C3=A5kon=20Sandsmark?= Date: Tue, 27 Feb 2018 20:57:35 +0000 Subject: [PATCH] PR c++/71546 - lambda init-capture with qualified-id. * parser.c (cp_parser_lambda_introducer): Clear scope after each lambda capture. From-SVN: r258043 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 6 ++++++ gcc/testsuite/g++.dg/cpp1y/lambda-init17.C | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-init17.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dbb678cbd48..20c15e4bec1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-02-27 HÃ¥kon Sandsmark + + 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 PR c++/84426 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index bcee1214c2f..e02d4bf1710 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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); diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init17.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init17.C new file mode 100644 index 00000000000..6c7cb449143 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init17.C @@ -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]() {}; +} -- 2.30.2