From: Jason Merrill Date: Thu, 24 Aug 2006 16:35:03 +0000 (-0400) Subject: re PR c++/27714 (operator new as friend in template class rejected) X-Git-Tag: releases/gcc-4.0.4~422 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05b996288be807d2b9844af2981086c92954a36a;p=thirdparty%2Fgcc.git re PR c++/27714 (operator new as friend in template class rejected) PR c++/27714 * pt.c (push_template_decl_real): A friend template with class scope isn't primary. From-SVN: r116381 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c865690eb00a..ddaaa05669b7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-08-23 Jason Merrill + + PR c++/27714 + * pt.c (push_template_decl_real): A friend template with class + scope isn't primary. + 2006-08-22 Jason Merrill PR c++/23372 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c296c715c31f..9f22cc367d8a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 friend void A::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 index 000000000000..17dc0db943bc --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend46.C @@ -0,0 +1,9 @@ +// PR c++/27714 + +template struct A +{ + static void* operator new(__SIZE_TYPE__); + template friend void* A::operator new(__SIZE_TYPE__); +}; + +A a;