This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH to push_template_decl_real for c++/27714


push_template_decl_real was assuming that if the innermost active scope is template parms then it's a primary template, but this isn't accurate for friend templates, which can use them to specify a member of a template class.

The only time a friend template can be primary is if it's an unqualified name, so the patch checks for that.

Tested x86_64-pc-linux-gnu, applied to trunk, 4.0, 4.1.
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.

Index: cp/pt.c
===================================================================
*** cp/pt.c	(revision 116368)
--- cp/pt.c	(working copy)
*************** push_template_decl_real (tree decl, bool
*** 3022,3028 ****
      DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
  
    /* See if this is a primary template.  */
!   primary = template_parm_scope_p ();
  
    if (primary)
      {
--- 3022,3034 ----
      DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
  
    /* See if this is a primary template.  */
!   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)
      {
Index: testsuite/g++.dg/template/friend46.C
===================================================================
*** testsuite/g++.dg/template/friend46.C	(revision 0)
--- testsuite/g++.dg/template/friend46.C	(revision 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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]