This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix c++/59112 and c++/59113: Disallow implicit function templates in local functions unless defining a lambda.
- From: Adam Butcher <adam at jessamine dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Jason Merrill <jason at redhat dot com>, Volker Reichelt <reichelt at gcc dot gnu dot org>, Adam Butcher <adam at jessamine dot co dot uk>
- Date: Sun, 24 Nov 2013 19:32:05 +0000
- Subject: [PATCH] Fix c++/59112 and c++/59113: Disallow implicit function templates in local functions unless defining a lambda.
- Authentication-results: sourceware.org; auth=none
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.
---
gcc/cp/parser.c | 4 +++-
gcc/testsuite/g++.dg/cpp1y/pr58533.C | 2 +-
gcc/testsuite/g++.dg/cpp1y/pr59112.C | 12 ++++++++++++
gcc/testsuite/g++.dg/cpp1y/pr59113.C | 11 +++++++++++
4 files changed, 27 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr59112.C
create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr59113.C
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index eaad8e4..1a26811 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -18026,7 +18026,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);
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58533.C b/gcc/testsuite/g++.dg/cpp1y/pr58533.C
index e1855d7..9bcd771 100644
--- a/gcc/testsuite/g++.dg/cpp1y/pr58533.C
+++ b/gcc/testsuite/g++.dg/cpp1y/pr58533.C
@@ -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
index 0000000..e7326ac
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr59112.C
@@ -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
index 0000000..f909a76
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr59113.C
@@ -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;
--
1.8.4