]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/60605 (incorrect diagosis of default template argument for function declara...
authorJason Merrill <jason@redhat.com>
Tue, 17 Jun 2014 23:03:43 +0000 (19:03 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 17 Jun 2014 23:03:43 +0000 (19:03 -0400)
PR c++/60605
* pt.c (check_default_tmpl_args): Check DECL_LOCAL_FUNCTION_P.

From-SVN: r211753

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/local-fn1.C [new file with mode: 0644]

index f3d7c8c9c72996fa5f7493ef4f8717a90a91b38d..c89da1356e10407997a0f9dd3cbb71681d717e52 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-17  Jason Merrill  <jason@redhat.com>
+
+       PR c++/60605
+       * pt.c (check_default_tmpl_args): Check DECL_LOCAL_FUNCTION_P.
+
 2014-06-02  Jason Merrill  <jason@redhat.com>
 
        PR c++/61134
index 85b46fe0809c64642a5b54e61031bbc83c3862c0..a4e1a591f9ab75e7ce45b35a5814c53ae23ea09f 100644 (file)
@@ -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 (file)
index 0000000..88acd17
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/60605
+
+template <typename T = int>
+struct Foo {
+    void bar() {
+        void bug();
+    }
+};