This is the mail archive of the gcc-bugs@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]

PATCH for explicit instantiation of member template constructors



This didn't use to work:

  template <class T>
  struct S
  {
    S(const T&) {}
    S(int, long);
  };

  template S<double>::S(const double&);

This patch fixes the problem.

-- 
Mark Mitchell <mmitchell@usa.net>
http://home.earthlink.net/~mbmitchell
Consulting Services Available

Tue Apr 21 12:10:18 1998  Mark Mitchell  <mmitchell@usa.net>

	* pt.c (check_explicit_specialization): Handle overloaded
	constructors correctly.

Index: gcc/cp/pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.117
diff -c -p -r1.117 pt.c
*** pt.c	1998/04/17 21:25:37	1.117
--- pt.c	1998/04/21 19:07:05
*************** check_explicit_specialization (declarato
*** 1039,1047 ****
  
  		  return decl;
  		}
  
! 	      fns = TREE_VEC_ELT(CLASSTYPE_METHOD_VEC (ctype),
! 				 is_constructor ? 0 : 1);
  	    }
  	  else 
  	    fns = lookup_fnfields (TYPE_BINFO (ctype), name,
--- 1077,1095 ----
  
  		  return decl;
  		}
+ 
+ 	      fns = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (ctype),
+ 				  is_constructor ? 0 : 1);
  
! 	      if (is_constructor)
! 		/* The constructor might well be overloaded.  But, the
! 		   entry in the CLASSTYPE_METHOD_VEC is not a
! 		   TREE_LIST node.  We build a TREE_LIST here so that
! 		   in further processing we can tree the constructors
! 		   just like any other set of overloaded functions.  */
! 		fns = scratch_tree_cons (NULL_TREE,
! 					 fns,
! 					 NULL_TREE);
  	    }
  	  else 
  	    fns = lookup_fnfields (TYPE_BINFO (ctype), name,
Index: gcc/testsuite/g++.old-deja/g++.pt/instantiate3.C
===================================================================
RCS file: instantiate3.C
diff -N instantiate3.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- instantiate3.C	Tue Apr 21 12:07:05 1998
***************
*** 0 ****
--- 1,10 ----
+ // Build don't link:
+ 
+ template <class T>
+ struct S
+ {
+   S(const T&) {}
+   S(int, long);
+ };
+ 
+ template S<double>::S(const double&);


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