]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Disallow implicit function templates in local functions unless defining a lambda.
authorAdam Butcher <adam@jessamine.co.uk>
Mon, 25 Nov 2013 07:43:55 +0000 (07:43 +0000)
committerAdam Butcher <abutcher@gcc.gnu.org>
Mon, 25 Nov 2013 07:43:55 +0000 (07:43 +0000)
gcc/cp/
PR c++/59112
PR c++/59113
* parser.c (cp_parser_parameter_declaration_clause): Disallow implicit
function templates in local functions unless defining a lambda.

gcc/testsuite/
PR c++/59112
PR c++/59113
g++.dg/cpp1y/pr58533.C: Updated testcase.
g++.dg/cpp1y/pr59112.C: New testcase.
g++.dg/cpp1y/pr59113.C: New testcase.

From-SVN: r205343

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

index aadecddc4138e9b91cb33ef963222a9499c4d316..92b520b45edebba681af3fe641da0952a3b2dd9c 100644 (file)
@@ -1,3 +1,10 @@
+2013-11-25  Adam Butcher  <adam@jessamine.co.uk>
+
+       PR c++/59112
+       PR c++/59113
+       * parser.c (cp_parser_parameter_declaration_clause): Disallow implicit
+       function templates in local functions unless defining a lambda.
+
 2013-11-23  Easwaran Raman  <eraman@google.com>
 
        PR c++/59031
index 141974745b15c7b3111986adc86532a3381696bb..d7092cc6759bc2b9fb7199f965d13864c0c165e3 100644 (file)
@@ -18042,7 +18042,9 @@ cp_parser_parameter_declaration_clause (cp_parser* parser)
   (void) cleanup;
 
   if (!processing_specialization)
-    parser->auto_is_implicit_function_template_parm_p = true;
+    if (!current_function_decl
+       || (current_class_type && LAMBDA_TYPE_P (current_class_type)))
+      parser->auto_is_implicit_function_template_parm_p = true;
 
   /* Peek at the next token.  */
   token = cp_lexer_peek_token (parser->lexer);
index a2e144f3bd311c9c8e75cfce6e6c344657c380c2..ddc0fa21167fee3d9680e058ceb89f3057780e5f 100644 (file)
@@ -1,3 +1,11 @@
+2013-11-25  Adam Butcher  <adam@jessamine.co.uk>
+
+       PR c++/59112
+       PR c++/59113
+       g++.dg/cpp1y/pr58533.C: Updated testcase.
+       g++.dg/cpp1y/pr59112.C: New testcase.
+       g++.dg/cpp1y/pr59113.C: New testcase.
+
 2013-11-25  Terry Guo  <terry.guo@arm.com>
 
        * gcc.target/arm/thumb2-slow-flash-data.c: New.
index e1855d78e084e7e56cd4cf2d650499227f03a43d..9bcd7716697fa8147f082c7e8a1bf464208353ef 100644 (file)
@@ -3,5 +3,5 @@
 
 void foo()
 {
-  void (*fp)(auto); // { dg-error "template" }
+  void (*fp)(auto); // { dg-error "auto|not permitted" }
 }
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59112.C b/gcc/testsuite/g++.dg/cpp1y/pr59112.C
new file mode 100644 (file)
index 0000000..e7326ac
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++1y" }
+
+// PR c++/59112
+
+void foo()
+{
+  struct A
+  {
+    A(auto) {} // { dg-error "auto|not permitted" }
+  };
+}
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59113.C b/gcc/testsuite/g++.dg/cpp1y/pr59113.C
new file mode 100644 (file)
index 0000000..f909a76
--- /dev/null
@@ -0,0 +1,11 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++1y" }
+
+// PR c++/59113
+
+void foo()
+{
+  void bar(auto) {} // { dg-error "function-definition|auto|not permitted" }
+}
+
+auto i = 0;