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]

[PATCH] Fix PR22371, enable type-checking for all stages


This patch fixes PR22371, pointer type checking errors with 
re-declarations in C.  The fix is to teach gimplification to mediate
between the type system differences of the frontends vs. the middle-end
as far as pointers(!) are concerned.  Pointers is where additional
conversions do not result in code changes but middle-end type correctness
is required to fulfill invariants the middle-end expects.

This patch also enables type-checking for all stages and not only
stage1, so all of the runtimes and testsuites get coverage.

Bootstrapped and tested on x86_64-unknown-linux-gnu for all languages.

Ok for mainline?

Thanks,
Richard.

2008-03-23  Richard Guenther  <rguenther@suse.de>

	PR c/22371
	* gimplify.c (gimplify_modify_expr): For frontend type-correct
	pointer assignments change conversions according to middle-end rules.
	(gimplify_modify_expr_rhs): Deal with NULL TARGET_EXPR_INITIAL.
	* configure.ac: Include type checking in yes.

Index: gimplify.c
===================================================================
*** gimplify.c	(revision 133461)
--- gimplify.c	(working copy)
*************** gimplify_modify_expr_rhs (tree *expr_p, 
*** 3599,3605 ****
  	     references somehow.  */
  	  tree init = TARGET_EXPR_INITIAL (*from_p);
  
! 	  if (!VOID_TYPE_P (TREE_TYPE (init)))
  	    {
  	      *from_p = init;
  	      ret = GS_OK;
--- 3599,3606 ----
  	     references somehow.  */
  	  tree init = TARGET_EXPR_INITIAL (*from_p);
  
! 	  if (init
! 	      && !VOID_TYPE_P (TREE_TYPE (init)))
  	    {
  	      *from_p = init;
  	      ret = GS_OK;
*************** gimplify_modify_expr (tree *expr_p, tree
*** 3870,3875 ****
--- 3871,3887 ----
  	      || TREE_CODE (*expr_p) == GIMPLE_MODIFY_STMT
  	      || TREE_CODE (*expr_p) == INIT_EXPR);
  
+   /* Insert pointer conversions required by the middle-end that are not
+      required by the frontend.  This fixes middle-end type checking for
+      for example gcc.dg/redecl-6.c.  */
+   if (POINTER_TYPE_P (TREE_TYPE (*to_p))
+       && lang_hooks.types_compatible_p (TREE_TYPE (*to_p), TREE_TYPE (*from_p)))
+     {
+       STRIP_USELESS_TYPE_CONVERSION (*from_p);
+       if (!useless_type_conversion_p (TREE_TYPE (*to_p), TREE_TYPE (*from_p)))
+ 	*from_p = fold_convert (TREE_TYPE (*to_p), *from_p);
+     }
+ 
    /* See if any simplifications can be done based on what the RHS is.  */
    ret = gimplify_modify_expr_rhs (expr_p, from_p, to_p, pre_p, post_p,
  				  want_value);
Index: configure.ac
===================================================================
*** configure.ac	(revision 133461)
--- configure.ac	(working copy)
*************** do
*** 367,373 ****
  			ac_gc_always_collect= ; ac_rtl_checking= ;
  			ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
  			ac_tree_checking=1 ; ac_valgrind_checking= ;
! 			ac_types_checking= ;;
  	no|none)	ac_assert_checking= ; ac_checking= ; ac_df_checking= ;
  			ac_fold_checking= ; ac_gc_checking= ;
  			ac_gc_always_collect= ; ac_rtl_checking= ;
--- 367,373 ----
  			ac_gc_always_collect= ; ac_rtl_checking= ;
  			ac_rtlflag_checking=1 ; ac_runtime_checking=1 ;
  			ac_tree_checking=1 ; ac_valgrind_checking= ;
! 			ac_types_checking=1 ;;
  	no|none)	ac_assert_checking= ; ac_checking= ; ac_df_checking= ;
  			ac_fold_checking= ; ac_gc_checking= ;
  			ac_gc_always_collect= ; ac_rtl_checking= ;


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