]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix out-of-line definition of class template generic member functions.
authorAdam Butcher <adam@jessamine.co.uk>
Tue, 25 Feb 2014 03:47:35 +0000 (03:47 +0000)
committerAdam Butcher <abutcher@gcc.gnu.org>
Tue, 25 Feb 2014 03:47:35 +0000 (03:47 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/fn-generic-member-ool.C [new file with mode: 0644]

index a5f2ec2598fe6ea1ec481a9fa8aacb61fa99b4e5..fa6b3cfea80b8e29c58db7d719dd241728ee9692 100644 (file)
@@ -1,5 +1,9 @@
 2014-02-25  Adam Butcher  <adam@jessamine.co.uk>
 
+       * 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
index 038e8530527ebcba088fa5681aabe11fca14b226..2d7918c64c70f32da188ecbb607b6009704cac4d 100644 (file)
@@ -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.  */
index b05509f6b65291f48294563296d10b8ac1f600fa..d59f4ece021c1eddaf022b3e936334db7defa87f 100644 (file)
@@ -1,5 +1,7 @@
 2014-02-25  Adam Butcher  <adam@jessamine.co.uk>
 
+       * 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 (file)
index 0000000..f9c814e
--- /dev/null
@@ -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 <typename T>
+struct B {
+  void f(auto x);
+};
+
+template <typename T>
+void B<T>::f(auto x) {}  // injects a new list
+
+struct C {
+  template <int N>
+  void f(auto x);
+};
+
+template <int N>
+void C::f(auto x) {}  // extends existing inner list
+
+template <typename T>
+struct D
+{
+  template <int N>
+  void f(auto x);
+};
+
+template <typename T>
+template <int N>
+void D<T>::f(auto x) {}  // extends existing inner list