This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR c++/60311.


	PR c++/60311
	* parser.c (function_being_declared_is_template_p): Return false when
	processing a template parameter list.
	(cp_parser_parameter_declaration_clause): Don't set
	auto_is_implicit_function_template_parm_p when processing a
	template parameter list.

	PR c++/60311
	* g++.dg/cpp1y/pr60311.C: New testcase.
---
 gcc/cp/parser.c                      |  4 ++--
 gcc/testsuite/g++.dg/cpp1y/pr60311.C | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr60311.C

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 2d7918c..ef36327 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -18122,7 +18122,7 @@ cp_parser_type_specifier_seq (cp_parser* parser,
 static bool
 function_being_declared_is_template_p (cp_parser* parser)
 {
-  if (!current_template_parms)
+  if (!current_template_parms || processing_template_parmlist)
     return false;
 
   if (parser->implicit_template_scope)
@@ -18165,7 +18165,7 @@ cp_parser_parameter_declaration_clause (cp_parser* parser)
 
   (void) cleanup;
 
-  if (!processing_specialization)
+  if (!processing_specialization && !processing_template_parmlist)
     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/pr60311.C b/gcc/testsuite/g++.dg/cpp1y/pr60311.C
new file mode 100644
index 0000000..a0db22d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr60311.C
@@ -0,0 +1,15 @@
+// PR c++/60311
+// { dg-options -std=c++1y }
+
+template<void(*)(auto)> struct A {}; // { dg-error "auto" }
+
+struct B {
+  template<void(*)(auto)> struct A {}; // { dg-error "auto" }
+};
+
+template <typename T>
+struct C {
+  template<void(*)(auto)> struct A {}; // { dg-error "auto" }
+};
+
+using D = C<int>;
-- 
1.9.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]