summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorabutcher <abutcher@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-25 07:43:55 +0000
committerabutcher <abutcher@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-25 07:43:55 +0000
commit2b7d858c79410630f5a154874f394c5f95a7e2ad (patch)
tree7f720b0c9e4110c48d04a4c1bce549fed22023b5
parent861033d5daa8c977326805754920f31641a9d5fe (diff)
downloadgcc-2b7d858c79410630f5a154874f394c5f95a7e2ad.tar.gz
Disallow implicit function templates in local functions unless defining a lambda.
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205343 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c4
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/pr58533.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/pr59112.C12
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/pr59113.C11
6 files changed, 42 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index aadecddc413..92b520b45ed 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 141974745b1..d7092cc6759 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a2e144f3bd3..ddc0fa21167 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58533.C b/gcc/testsuite/g++.dg/cpp1y/pr58533.C
index e1855d78e08..9bcd7716697 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 00000000000..e7326ac3113
--- /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 00000000000..f909a76bd35
--- /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;