diff mbox

Fix PR c++/59629

Message ID 1388823981-20855-1-git-send-email-adam@jessamine.co.uk
State New
Headers show

Commit Message

Adam Butcher Jan. 4, 2014, 8:26 a.m. UTC
* cp/parser.c (cp_parser_lambda_expression): Save/reset/restore
	auto_is_implicit_function_template_parm_p around lambda body.

	* g++.dg/cpp1y/pr59629.C: New testcase.
---
 gcc/cp/parser.c                      | 5 +++++
 gcc/testsuite/g++.dg/cpp1y/pr59629.C | 7 +++++++
 2 files changed, 12 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr59629.C

Comments

Jason Merrill Jan. 6, 2014, 2:48 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4f737df..0e013b9 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -8740,6 +8740,8 @@  cp_parser_lambda_expression (cp_parser* parser)
         = parser->fully_implicit_function_template_p;
     tree implicit_template_parms = parser->implicit_template_parms;
     cp_binding_level* implicit_template_scope = parser->implicit_template_scope;
+    bool auto_is_implicit_function_template_parm_p
+        = parser->auto_is_implicit_function_template_parm_p;
 
     parser->num_template_parameter_lists = 0;
     parser->in_statement = 0;
@@ -8747,6 +8749,7 @@  cp_parser_lambda_expression (cp_parser* parser)
     parser->fully_implicit_function_template_p = false;
     parser->implicit_template_parms = 0;
     parser->implicit_template_scope = 0;
+    parser->auto_is_implicit_function_template_parm_p = false;
 
     /* By virtue of defining a local class, a lambda expression has access to
        the private variables of enclosing classes.  */
@@ -8774,6 +8777,8 @@  cp_parser_lambda_expression (cp_parser* parser)
 	= fully_implicit_function_template_p;
     parser->implicit_template_parms = implicit_template_parms;
     parser->implicit_template_scope = implicit_template_scope;
+    parser->auto_is_implicit_function_template_parm_p
+	= auto_is_implicit_function_template_parm_p;
   }
 
   pop_deferring_access_checks ();
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59629.C b/gcc/testsuite/g++.dg/cpp1y/pr59629.C
new file mode 100644
index 0000000..a0c9209
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr59629.C
@@ -0,0 +1,7 @@ 
+// { dg-do compile }
+// { dg-options "-std=c++1y" }
+
+// PR c++/59629
+
+void foo(int i = []{ auto 0; }()); // { dg-error "expected|could not convert" }
+