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++) template waste patch


For code like

  template <class T> T f (T);

  inline void g ()
  {
    f (42);
  }

  template <class T> T f (T t) { return t; }

we were emitting f even though we don't emit g, because it was instantiated
from the pending_templates list at EOF, so it got DECL_INTERFACE_KNOWN, so
things thought it shouldn't be deferred.  This patch fixes that:

1999-11-13  Jason Merrill  <jason@yorick.cygnus.com>

	* decl.c (duplicate_decls): Propagate DECL_DEFER_OUTPUT.
	* decl2.c (comdat_linkage): Set DECL_DEFER_OUTPUT.

Index: decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.498
diff -c -p -r1.498 decl.c
*** decl.c	1999/11/12 17:11:06	1.498
--- decl.c	1999/11/13 09:37:50
*************** duplicate_decls (newdecl, olddecl)
*** 3408,3413 ****
--- 3408,3414 ----
    /* Merge the storage class information.  */
    DECL_WEAK (newdecl) |= DECL_WEAK (olddecl);
    DECL_ONE_ONLY (newdecl) |= DECL_ONE_ONLY (olddecl);
+   DECL_DEFER_OUTPUT (newdecl) |= DECL_DEFER_OUTPUT (olddecl);
    TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
    TREE_STATIC (olddecl) = TREE_STATIC (newdecl) |= TREE_STATIC (olddecl);
    if (! DECL_EXTERNAL (olddecl))
Index: decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.277
diff -c -p -r1.277 decl2.c
*** decl2.c	1999/11/05 23:11:57	1.277
--- decl2.c	1999/11/13 09:37:51
*************** comdat_linkage (decl)
*** 2355,2360 ****
--- 2355,2363 ----
  
    if (DECL_LANG_SPECIFIC (decl))
      DECL_COMDAT (decl) = 1;
+ 
+   if (TREE_CODE (decl) == FUNCTION_DECL)
+     DECL_DEFER_OUTPUT (decl) = 1;
  }
  
  /* For win32 we also want to put explicit instantiations in


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