@@ -31906,7 +31906,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. */
new file mode 100644
@@ -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