]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/59629 ([c++11] ICE with invalid use of auto in lambda function)
authorAdam Butcher <adam@jessamine.co.uk>
Mon, 6 Jan 2014 18:22:38 +0000 (18:22 +0000)
committerAdam Butcher <abutcher@gcc.gnu.org>
Mon, 6 Jan 2014 18:22:38 +0000 (18:22 +0000)
Fix PR c++/59629

PR c++/59629
* 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.

From-SVN: r206370

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

index 33228977ca5db7f4433bf05044b87a0e02960ce0..c58594602436b1570af2746bf7602e9260c23183 100644 (file)
@@ -8,6 +8,10 @@
        * cp/parser.c (cp_parser_template_parameter): Early out with
        error_mark_node if parameter declaration was not parsed.
 
+       PR c++/59629
+       * cp/parser.c (cp_parser_lambda_expression): Save/reset/restore
+       auto_is_implicit_function_template_parm_p around lambda body.
+
 2014-01-03  Marc Glisse  <marc.glisse@inria.fr>
 
        PR c++/58950
index 4d970260a1b31201ab4eeab6264bde2b3ac289ec..6668f2ce5c02c306fd6b8969cf7edeac9b11196c 100644 (file)
@@ -8738,6 +8738,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;
@@ -8745,6 +8747,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.  */
@@ -8772,6 +8775,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 ();
index a56b69dbb64e53c84ea66e62e199bf5a1064ce60..036b91adf4a68a8ea9394cae79ea4a6807b5731b 100644 (file)
@@ -2,8 +2,10 @@
 
        PR c++/59635
        PR c++/59636
+       PR c++/59629
        * g++.dg/cpp1y/pr59635.C: New testcase.
        * g++.dg/cpp1y/pr59636.C: New testcase.
+       * g++.dg/cpp1y/pr59629.C: New testcase.
 
 2014-01-06  Martin Jambor  <mjambor@suse.cz>
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59629.C b/gcc/testsuite/g++.dg/cpp1y/pr59629.C
new file mode 100644 (file)
index 0000000..a0c9209
--- /dev/null
@@ -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" }
+