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: PR 13925


This patch fixes a name-lookup regression in templates.

Tested on i686-pc-linux-gnu, applied on the mainline and on the 3.4
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-02-03  Mark Mitchell  <mark@codesourcery.com>

	PR c++/13925
	* decl.c (start_function): Do not call pushdecl for any
	instantiation or specialization of a primary template.

2004-02-03  Mark Mitchell  <mark@codesourcery.com>

	PR c++/13925
	* g++.dg/template/lookup5.C: New test.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1174.2.3
diff -c -5 -p -r1.1174.2.3 decl.c
*** cp/decl.c	2 Feb 2004 16:26:37 -0000	1.1174.2.3
--- cp/decl.c	3 Feb 2004 19:22:47 -0000
*************** start_function (tree declspecs, tree dec
*** 10270,10281 ****
       If we already have a decl for this name, and it is a FUNCTION_DECL,
       use the old decl.  */
    if (!processing_template_decl && !(flags & SF_PRE_PARSED))
      {
        /* A specialization is not used to guide overload resolution.  */
!       if (!DECL_TEMPLATE_SPECIALIZATION (decl1)
! 	  && ! DECL_FUNCTION_MEMBER_P (decl1))
  	{
  	  tree olddecl = pushdecl (decl1);
  
  	  if (olddecl == error_mark_node)
  	    /* If something went wrong when registering the declaration,
--- 10270,10282 ----
       If we already have a decl for this name, and it is a FUNCTION_DECL,
       use the old decl.  */
    if (!processing_template_decl && !(flags & SF_PRE_PARSED))
      {
        /* A specialization is not used to guide overload resolution.  */
!       if (!DECL_FUNCTION_MEMBER_P (decl1)
! 	  && !(DECL_USE_TEMPLATE (decl1) && 
! 	       PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (decl1))))
  	{
  	  tree olddecl = pushdecl (decl1);
  
  	  if (olddecl == error_mark_node)
  	    /* If something went wrong when registering the declaration,
Index: testsuite/g++.dg/template/lookup5.C
===================================================================
RCS file: testsuite/g++.dg/template/lookup5.C
diff -N testsuite/g++.dg/template/lookup5.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/lookup5.C	3 Feb 2004 19:29:40 -0000
***************
*** 0 ****
--- 1,17 ----
+ // PR c++/13925
+ 
+ namespace N {
+   template <class T> void f(T);
+ 
+   namespace M {
+     class A {
+       friend void f<int>(int);
+     };
+   }
+ 
+   template <class T> void f(T) {}
+   template <> void f<int>(int )
+   { 
+     f<long>(0);
+   }
+ }


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