From: Adam Butcher Date: Tue, 25 Feb 2014 03:47:35 +0000 (+0000) Subject: Fix out-of-line definition of class template generic member functions. X-Git-Tag: releases/gcc-4.9.0~708 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b859733ce1f05552a13d2ed705623f860848559;p=thirdparty%2Fgcc.git Fix out-of-line definition of class template generic member functions. * 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. * g++.dg/cpp1y/fn-generic-member-ool.C: New testcase. From-SVN: r208107 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a5f2ec2598fe..fa6b3cfea80b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-02-25 Adam Butcher + * 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. + PR c++/60065 * parser.c (cp_parser_direct_declarator): Don't save and restore num_template_parameter_lists around call to diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 038e8530527e..2d7918c64c70 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -31942,7 +31942,8 @@ synthesize_implicit_template_parm (cp_parser *parser) current_binding_level = scope; - if (scope->kind != sk_template_parms) + if (scope->kind != sk_template_parms + || !function_being_declared_is_template_p (parser)) { /* Introduce a new template parameter list for implicit template parameters. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b05509f6b652..d59f4ece021c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2014-02-25 Adam Butcher + * g++.dg/cpp1y/fn-generic-member-ool.C: New testcase. + PR c++/60065 * g++.dg/cpp1y/pr60065.C: New testcase. diff --git a/gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C b/gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C new file mode 100644 index 000000000000..f9c814ee081f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C @@ -0,0 +1,35 @@ +// Out-of-line generic member function definitions. +// { dg-options "-std=c++1y" } + +struct A { + void f(auto x); +}; + +void A::f(auto x) {} // injects a new list + +template +struct B { + void f(auto x); +}; + +template +void B::f(auto x) {} // injects a new list + +struct C { + template + void f(auto x); +}; + +template +void C::f(auto x) {} // extends existing inner list + +template +struct D +{ + template + void f(auto x); +}; + +template +template +void D::f(auto x) {} // extends existing inner list