re PR c++/60190 ([c++1y] ICE with invalid return type of template lambda)
authorAdam Butcher <adam@jessamine.co.uk>
Tue, 18 Feb 2014 21:07:48 +0000 (21:07 +0000)
committerAdam Butcher <abutcher@gcc.gnu.org>
Tue, 18 Feb 2014 21:07:48 +0000 (21:07 +0000)
Fix PR c++/60190.

PR c++/60190
* parser.c (cp_parser_lambda_declarator_opt): Pop template parameter
scope whenever a template parameter list has been started, independent
of whether the function call operator was well-formed or not.

PR c++/60190
* g++.dg/cpp1y/pr60190.C: New testcase.

From-SVN: r207852

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

index 3d2c6b2261d097db3851e31f1245e666c6c6b689..b0fd4b7f36b0ae726269e71b7af07c21377652c4 100644 (file)
@@ -1,3 +1,10 @@
+2014-02-18  Adam Butcher  <adam@jessamine.co.uk>
+
+       PR c++/60190
+       * parser.c (cp_parser_lambda_declarator_opt): Pop template parameter
+       scope whenever a template parameter list has been started, independent
+       of whether the function call operator was well-formed or not.
+
 2014-02-12  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/60047
index f0722d6bf7bc031433b137d2943f7a45ca935053..23d54fb12863d64921626a80ffd7c13b392c9c87 100644 (file)
@@ -9127,15 +9127,15 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
        DECL_ARTIFICIAL (fco) = 1;
        /* Give the object parameter a different name.  */
        DECL_NAME (DECL_ARGUMENTS (fco)) = get_identifier ("__closure");
-       if (template_param_list)
-         {
-           fco = finish_member_template_decl (fco);
-           finish_template_decl (template_param_list);
-           --parser->num_template_parameter_lists;
-         }
-       else if (parser->fully_implicit_function_template_p)
-         fco = finish_fully_implicit_template (parser, fco);
       }
+    if (template_param_list)
+      {
+       fco = finish_member_template_decl (fco);
+       finish_template_decl (template_param_list);
+       --parser->num_template_parameter_lists;
+      }
+    else if (parser->fully_implicit_function_template_p)
+      fco = finish_fully_implicit_template (parser, fco);
 
     finish_member_declaration (fco);
 
index 430ea451da07f4dbe219d4047fdf80b94f992f35..cd31dd90528e9997ac8190c20d7c86fbe9d2953e 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-18  Adam Butcher  <adam@jessamine.co.uk>
+
+       PR c++/60190
+       * g++.dg/cpp1y/pr60190.C: New testcase.
+
 2014-02-18  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/60205
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60190.C b/gcc/testsuite/g++.dg/cpp1y/pr60190.C
new file mode 100644 (file)
index 0000000..d5e2567
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/60190
+// { dg-do compile }
+// { dg-options "-std=c++1y" }
+
+auto f = []<int>() -> int() {}; // { dg-error "returning a function|expected" }