]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/71546 - lambda init-capture with qualified-id.
authorHåkon Sandsmark <hsandsmark@gmail.com>
Tue, 27 Feb 2018 20:57:35 +0000 (20:57 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 27 Feb 2018 20:57:35 +0000 (15:57 -0500)
* parser.c (cp_parser_lambda_introducer): Clear scope after
each lambda capture.

From-SVN: r258043

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp1y/lambda-init17.C [new file with mode: 0644]

index dbb678cbd48c795d7d5f5d197de4a24d25111553..20c15e4bec1ff29c0ed92089ad822c082dca6d07 100644 (file)
@@ -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
index bcee1214c2f36827f9956afeaa9f786adc769720..e02d4bf171006d522e7d507d12b0f79aa95d68b8 100644 (file)
@@ -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 (file)
index 0000000..6c7cb44
--- /dev/null
@@ -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]() {};
+}