The exception for local declarations in check_default_tmpl_args needs to
handle DECL_LOCAL_FUNCTION_P, too.
Tested x86_64-pc-linux-gnu, applying to 4.8, 4.9, trunk.
commit 424c657e1213126dc5d2a7231abac05e16713286
Author: Jason Merrill <ja...@redhat.com>
Date: Tue Jun 17 18:43:57 2014 +0200
PR c++/60605
* pt.c (check_default_tmpl_args): Check DECL_LOCAL_FUNCTION_P.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 85b46fe..a4e1a59 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4308,7 +4308,8 @@ check_default_tmpl_args (tree decl, tree parms, bool is_primary,
in the template-parameter-list of the definition of a member of a
class template. */
- if (TREE_CODE (CP_DECL_CONTEXT (decl)) == FUNCTION_DECL)
+ if (TREE_CODE (CP_DECL_CONTEXT (decl)) == FUNCTION_DECL
+ || (TREE_CODE (decl) == FUNCTION_DECL && DECL_LOCAL_FUNCTION_P (decl)))
/* You can't have a function template declaration in a local
scope, nor you can you define a member of a class template in a
local scope. */
diff --git a/gcc/testsuite/g++.dg/template/local-fn1.C b/gcc/testsuite/g++.dg/template/local-fn1.C
new file mode 100644
index 0000000..88acd17
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/local-fn1.C
@@ -0,0 +1,8 @@
+// PR c++/60605
+
+template <typename T = int>
+struct Foo {
+ void bar() {
+ void bug();
+ }
+};