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 for c++/17256


I started from James' patch for this, but ended up not using it because I didn't want to deal with the extra semantics implied by marking static functions as having vague linkage. It also ran into problems with functions declared with an asmspec where the definition was provided in a separate asm.

This patch mostly just removes the DECL_REALLY_EXTERN condition on the undefined warning, which is enough to fix the PR. If we want to change the handling of static functions, we should add functionality like the C front end's C_DECL_USED.

Tested x86_64-pc-linux-gnu, applied to trunk. Test in g++.dg/warn/undefined1.C.
2005-11-02  Jason Merrill  <jason@redhat.com>
	    James A. Morrison <phython@gcc.gnu.org>

	PR c++/17256
	* decl2.c (cp_finish_file): Fix conditions for undefined warning.
	Set TREE_NO_WARNING instead of TREE_PUBLIC.
	* pt.c (instantiate_pending_templates): Set DECL_INITIAL to avoid
	a warning on a function we didn't instantiate because of excessive
	recursion.

Index: pt.c
===================================================================
*** pt.c	(revision 106555)
--- pt.c	(working copy)
*************** instantiate_pending_templates (int retri
*** 11813,11822 ****
       to avoid infinite loop.  */
    if (pending_templates && retries >= max_tinst_depth)
      {
        error ("template instantiation depth exceeds maximum of %d"
! 	    " instantiating %q+D, possibly from virtual table generation"
! 	    " (use -ftemplate-depth-NN to increase the maximum)",
! 	    max_tinst_depth, TREE_VALUE (pending_templates));
        return;
      }
  
--- 11813,11827 ----
       to avoid infinite loop.  */
    if (pending_templates && retries >= max_tinst_depth)
      {
+       tree decl = TREE_VALUE (pending_templates);
+ 
        error ("template instantiation depth exceeds maximum of %d"
! 	     " instantiating %q+D, possibly from virtual table generation"
! 	     " (use -ftemplate-depth-NN to increase the maximum)",
! 	     max_tinst_depth, decl);
!       if (TREE_CODE (decl) == FUNCTION_DECL)
! 	/* Pretend that we defined it.  */
! 	DECL_INITIAL (decl) = error_mark_node;
        return;
      }
  
Index: decl2.c
===================================================================
*** decl2.c	(revision 106555)
--- decl2.c	(working copy)
*************** cp_finish_file (void)
*** 3062,3069 ****
      {
        if (/* Check online inline functions that were actually used.  */
  	  TREE_USED (decl) && DECL_DECLARED_INLINE_P (decl)
- 	  /* But not defined.  */
- 	  && DECL_REALLY_EXTERN (decl)
  	  /* If the definition actually was available here, then the
  	     fact that the function was not defined merely represents
  	     that for some reason (use of a template repository,
--- 3062,3067 ----
*************** cp_finish_file (void)
*** 3076,3085 ****
  	  && !DECL_EXPLICIT_INSTANTIATION (decl))
  	{
  	  warning (0, "inline function %q+D used but never defined", decl);
! 	  /* This symbol is effectively an "extern" declaration now.
! 	     This is not strictly necessary, but removes a duplicate
! 	     warning.  */
! 	  TREE_PUBLIC (decl) = 1;
  	}
      }
  
--- 3074,3081 ----
  	  && !DECL_EXPLICIT_INSTANTIATION (decl))
  	{
  	  warning (0, "inline function %q+D used but never defined", decl);
! 	  /* Avoid a duplicate warning from check_global_declaration_1.  */
! 	  TREE_NO_WARNING (decl) = 1;
  	}
      }
  

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