re PR c++/27714 (operator new as friend in template class rejected)
authorJason Merrill <jason@gcc.gnu.org>
Thu, 24 Aug 2006 15:54:39 +0000 (11:54 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 24 Aug 2006 15:54:39 +0000 (11:54 -0400)
        PR c++/27714
        * pt.c (push_template_decl_real): A friend template with class
        scope isn't primary.

From-SVN: r116379

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

index e2bc2dbb525df559f280bc19467f13c43589858e..e1ad1bff31e202a8e400b1ee00c8a5ea9a1c9cb8 100644 (file)
@@ -1,4 +1,10 @@
-2006-08-11   Benjamin Smedberg <benjamin@smedbergs.us>
+2006-08-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/27714
+       * pt.c (push_template_decl_real): A friend template with class 
+       scope isn't primary.
+
+2006-08-23  Benjamin Smedberg <benjamin@smedbergs.us>
 
        PR c++/28687
        * rtti.c (build_dynamic_cast, build_dynamic_cast_1):
index 4a58ef3cb6d8a68e860037db4c121befe0fe05f5..5843a50e57bb7387d2300dd12a65182c477d0bfb 100644 (file)
@@ -3022,7 +3022,13 @@ push_template_decl_real (tree decl, bool is_friend)
     DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
 
   /* See if this is a primary template.  */
-  primary = template_parm_scope_p ();
+  if (is_friend && ctx)
+    /* A friend template that specifies a class context, i.e.
+         template <typename T> friend void A<T>::f();
+       is not primary.  */
+    primary = 0;
+  else
+    primary = template_parm_scope_p ();
 
   if (primary)
     {
diff --git a/gcc/testsuite/g++.dg/template/friend46.C b/gcc/testsuite/g++.dg/template/friend46.C
new file mode 100644 (file)
index 0000000..17dc0db
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/27714
+
+template<typename> struct A
+{
+  static void* operator new(__SIZE_TYPE__);
+  template <typename T> friend void* A<T>::operator new(__SIZE_TYPE__);
+};
+
+A<int> a;