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]

[tree-ssa] Fix CHAIN uninitialized warning, cleanup type checking


The static chain pointer is initialized in a way that is not seen by the
tree-ssa analyzers and optimizers.  Thus it appears uninitialized and you'll
get warnings about the static chain being uninitialized if you use 
-Wuninitialized and nested functions.

This patch marks the static chain with TREE_NO_WARNING to suppress such
warnings.  This allows one more FC2 package to build with the tree-ssa
compiler (it uses nested functions with -Wuninitialized -Werror).

This patch also cleans up the type checking in tree-tailcall.c per
Richard, Diego & Dale's recommendations.

Bootstrapped and regression tested i686-pc-linux-gnu.

	* Makefile.in (tree-tailcall.o): Depend on langhooks.h.
	* tree-tailcall.c: Include langhooks.h. 
	(find_tail_calls): Use types_compatible_p langhook instead of 
	equality test of TYPE_MAIN_VARIANT.

	* tree-nested.c (get_chain_decl): Mark the chain decl with
	TREE_NO_WARNING.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.193
diff -c -p -r1.903.2.193 Makefile.in
*** Makefile.in	16 Mar 2004 22:16:26 -0000	1.903.2.193
--- Makefile.in	18 Mar 2004 21:17:57 -0000
*************** tree-cfg.o : tree-cfg.c $(TREE_FLOW_H) $
*** 1603,1609 ****
     $(TREE_DUMP_H) except.h langhooks.h cfgloop.h gt-tree-cfg.h tree-pass.h
  tree-tailcall.o : tree-tailcall.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
     $(RTL_H) $(TREE_H) $(TM_P_H) function.h $(TM_H) coretypes.h \
!    $(TREE_DUMP_H) diagnostic.h except.h tree-pass.h flags.h
  tree-nested.o: tree-nested.c $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(TREE_H) \
     $(RTL_H) $(TM_P_H) function.h tree-dump.h tree-inline.h tree-iterator.h \
     tree-simple.h cgraph.h $(EXPR_H) langhooks.h $(GGC_H) gt-tree-nested.h
--- 1603,1609 ----
     $(TREE_DUMP_H) except.h langhooks.h cfgloop.h gt-tree-cfg.h tree-pass.h
  tree-tailcall.o : tree-tailcall.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
     $(RTL_H) $(TREE_H) $(TM_P_H) function.h $(TM_H) coretypes.h \
!    $(TREE_DUMP_H) diagnostic.h except.h tree-pass.h flags.h langhooks.h
  tree-nested.o: tree-nested.c $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(TREE_H) \
     $(RTL_H) $(TM_P_H) function.h tree-dump.h tree-inline.h tree-iterator.h \
     tree-simple.h cgraph.h $(EXPR_H) langhooks.h $(GGC_H) gt-tree-nested.h
Index: tree-nested.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-nested.c,v
retrieving revision 1.1.2.3
diff -c -p -r1.1.2.3 tree-nested.c
*** tree-nested.c	11 Mar 2004 01:11:59 -0000	1.1.2.3
--- tree-nested.c	18 Mar 2004 21:18:33 -0000
*************** get_chain_decl (struct nesting_info *inf
*** 307,312 ****
--- 307,317 ----
        DECL_CONTEXT (decl) = info->context;
        decl->decl.seen_in_bind_expr = 1;
  
+       /* The initialization of CHAIN is not visible to the tree-ssa
+ 	 analyzers and optimizers.  Thus we do not want to issue
+ 	 warnings for CHAIN.  */
+       TREE_NO_WARNING (decl) = 1;
+ 
        /* Tell tree-inline.c that we never write to this variable, so
  	 it can copy-prop the replacement value immediately.  */
        TREE_READONLY (decl) = 1;
Index: tree-tailcall.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-tailcall.c,v
retrieving revision 1.1.2.23
diff -c -p -r1.1.2.23 tree-tailcall.c
*** tree-tailcall.c	17 Mar 2004 21:20:38 -0000	1.1.2.23
--- tree-tailcall.c	18 Mar 2004 21:18:34 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 34,39 ****
--- 34,40 ----
  #include "except.h"
  #include "tree-pass.h"
  #include "flags.h"
+ #include "langhooks.h"
  
  /* The file implements the tail recursion elimination.  It is also used to
     analyse the tail calls in general, passing the results to the rtl level
*************** find_tail_calls (basic_block bb, struct 
*** 406,420 ****
        for (param = DECL_ARGUMENTS (func), args = TREE_OPERAND (call, 1);
  	   param && args;
  	   param = TREE_CHAIN (param), args = TREE_CHAIN (args))
! 	if (param != TREE_VALUE (args)
! 	    /* Make sure there are no problems with copying.  Note we must
! 	       have a copyable type and the two arguments must have reasonably
! 	       equivalent types.  The latter requirement could be relaxed if
! 	       we emitted a suitable type conversion statement.  */
! 	    && (!is_gimple_reg_type (TREE_TYPE (param))
! 		|| (TYPE_MAIN_VARIANT (TREE_TYPE (param)) 
! 		    != TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (args))))))
! 	  break;
        if (!args && !param)
  	tail_recursion = true;
      }
--- 407,424 ----
        for (param = DECL_ARGUMENTS (func), args = TREE_OPERAND (call, 1);
  	   param && args;
  	   param = TREE_CHAIN (param), args = TREE_CHAIN (args))
! 	{
! 	  tree arg = TREE_VALUE (args);
! 	  if (param != arg
! 	      /* Make sure there are no problems with copying.  Note we must
! 	         have a copyable type and the two arguments must have reasonably
! 	         equivalent types.  The latter requirement could be relaxed if
! 	         we emitted a suitable type conversion statement.  */
! 	      && (!is_gimple_reg_type (TREE_TYPE (param))
! 		  || !lang_hooks.types_compatible_p (TREE_TYPE (param),
! 						     TREE_TYPE (arg))))
! 	    break;
! 	}
        if (!args && !param)
  	tail_recursion = true;
      }




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