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]

C++ PATCH: Fix PR2887



PR2887 refers to a failure of -frepo due to the infamous cloned
functions in the new ABI.

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

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2001-06-05  Mark Mitchell  <mark@codesourcery.com>

	* pt.c (instantiate_decl): Tell the repository code about the
	clones, not the cloned functions.
	* repo.c (repo_template_used): Explicitly instantiate the cloned
	function, not the clones.

Index: testsuite/g++.old-deja/g++.pt/repo4.C
===================================================================
RCS file: repo4.C
diff -N repo4.C
*** /dev/null	Tue May  5 13:32:27 1998
--- repo4.C	Tue Jun  5 20:12:41 2001
***************
*** 0 ****
--- 1,15 ----
+ // Build then link:
+ // Special g++ Options: -frepo
+ 
+ template <class T>
+ struct S {
+   ~S ();
+ };
+ 
+ template <class T>
+ S<T>::~S () {}
+ 
+ int main ()
+ {
+   S<int> s;
+ }
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.516.2.12
diff -c -p -r1.516.2.12 pt.c
*** pt.c	2001/05/01 12:54:44	1.516.2.12
--- pt.c	2001/06/06 03:12:44
*************** instantiate_decl (d, defer_ok)
*** 9854,9860 ****
  
    if (pattern_defined)
      {
!       repo_template_used (d);
  
        if (flag_external_templates && ! DECL_INTERFACE_KNOWN (d))
  	{
--- 9854,9878 ----
  
    if (pattern_defined)
      {
!       /* Let the repository code that this template definition is
! 	 available.
! 
! 	 The repository doesn't need to know about cloned functions
! 	 because they never actually show up in the object file.  It
! 	 does need to know about the clones; those are the symbols
! 	 that the linker will be emitting error messages about.  */
!       if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (d)
! 	  || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (d))
! 	{
! 	  tree t;
! 
! 	  for (t = TREE_CHAIN (d);
! 	       t && DECL_CLONED_FUNCTION_P (t); 
! 	       t = TREE_CHAIN (t))
! 	    repo_template_used (t);
! 	}
!       else
! 	repo_template_used (d);
  
        if (flag_external_templates && ! DECL_INTERFACE_KNOWN (d))
  	{
Index: cp/repo.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/repo.c,v
retrieving revision 1.33
diff -c -p -r1.33 repo.c
*** repo.c	2001/02/12 09:58:18	1.33
--- repo.c	2001/06/06 03:12:44
*************** repo_template_used (t)
*** 138,144 ****
    else if (DECL_P (t))
      {
        if (IDENTIFIER_REPO_CHOSEN (id))
! 	mark_decl_instantiated (t, 0);
      }
    else
      my_friendly_abort (1);
--- 138,150 ----
    else if (DECL_P (t))
      {
        if (IDENTIFIER_REPO_CHOSEN (id))
! 	/* It doesn't make sense to instantiate a clone, so we
! 	   instantiate the cloned function instead.  Note that this
! 	   approach will not work correctly if collect2 assigns
! 	   different clones to different files -- but it shouldn't.  */
! 	mark_decl_instantiated (DECL_CLONED_FUNCTION_P (t)
! 				? DECL_CLONED_FUNCTION (t) : t, 
! 				0);
      }
    else
      my_friendly_abort (1);


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