]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/27714 (operator new as friend in template class rejected)
authorJason Merrill <jason@redhat.com>
Thu, 24 Aug 2006 16:35:03 +0000 (12:35 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 24 Aug 2006 16:35:03 +0000 (12:35 -0400)
        PR c++/27714
        * pt.c (push_template_decl_real): A friend template with class
        scope isn't primary.

From-SVN: r116381

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

index c865690eb00afb65d79df706cd5b2c0354ddaa3e..ddaaa05669b7aad01c4c23981817cb0667c86d94 100644 (file)
@@ -1,3 +1,9 @@
+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-22  Jason Merrill  <jason@redhat.com>
 
        PR c++/23372
index c296c715c31ffa0dea4f90a65429f7c9068641b2..9f22cc367d8a9404d74ebca3393bf003c3eb31e0 100644 (file)
@@ -2947,7 +2947,13 @@ push_template_decl_real (tree decl, int 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;