[PATCH] Fix PR c++/60627

Adam Butcher adam@jessamine.co.uk
Sun Mar 23 20:57:00 GMT 2014


	PR c++/60627
	* parser.c (cp_parser_parameter_declaration_clause): Prevent 'auto' from
	introducing an implicit function template parameter within an explicit
	instantiation.

	PR c++/60627
	* g++.dg/cpp1y/pr60627.C: New testcase.
---
 gcc/cp/parser.c                      |  4 +++-
 gcc/testsuite/g++.dg/cpp1y/pr60627.C | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr60627.C

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 36872c9..efb7b39 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -18207,7 +18207,9 @@ cp_parser_parameter_declaration_clause (cp_parser* parser)
 
   (void) cleanup;
 
-  if (!processing_specialization && !processing_template_parmlist)
+  if (!processing_specialization
+      && !processing_template_parmlist
+      && !processing_explicit_instantiation)
     if (!current_function_decl
 	|| (current_class_type && LAMBDA_TYPE_P (current_class_type)))
       parser->auto_is_implicit_function_template_parm_p = true;
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60627.C b/gcc/testsuite/g++.dg/cpp1y/pr60627.C
new file mode 100644
index 0000000..9e2116e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr60627.C
@@ -0,0 +1,12 @@
+// PR c++/60627
+// { dg-do compile { target c++1y } }
+// { dg-options "" }
+
+template<typename T> void foo(T) {}
+
+template void foo(auto);  // { dg-error "auto|does not match" }
+
+void bar()
+{
+  foo(0);
+}
-- 
1.9.0



More information about the Gcc-patches mailing list