re PR c++/60311 ([c++1y] ICE with pointer-to-function with auto parameter)
authorAdam Butcher <adam@jessamine.co.uk>
Tue, 25 Feb 2014 06:44:53 +0000 (06:44 +0000)
committerAdam Butcher <abutcher@gcc.gnu.org>
Tue, 25 Feb 2014 06:44:53 +0000 (06:44 +0000)
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.

From-SVN: r208111

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

index fa6b3cfea80b8e29c58db7d719dd241728ee9692..5afc6d8e0d93a6f46bc437f68fe2a4044db716f1 100644 (file)
@@ -1,5 +1,12 @@
 2014-02-25  Adam Butcher  <adam@jessamine.co.uk>
 
+       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.
+
        * parser.c (synthesize_implicit_template_parm): Inject new template
        argument list appropriately when a generic member function
        of a class template is declared out-of-line.
index 2d7918c64c70f32da188ecbb607b6009704cac4d..ef363274471ccc6dc5d7d555fe3a47dcab58bfff 100644 (file)
@@ -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;
index d59f4ece021c1eddaf022b3e936334db7defa87f..d8d760ac009d308bb5ad7e9f36074f87afaaf3c4 100644 (file)
@@ -1,5 +1,8 @@
 2014-02-25  Adam Butcher  <adam@jessamine.co.uk>
 
+       PR c++/60311
+       * g++.dg/cpp1y/pr60311.C: New testcase.
+
        * g++.dg/cpp1y/fn-generic-member-ool.C: New testcase.
 
        PR c++/60065
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60311.C b/gcc/testsuite/g++.dg/cpp1y/pr60311.C
new file mode 100644 (file)
index 0000000..a0db22d
--- /dev/null
@@ -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>;