re PR c/22371 (C front-end produces mis-match types in MODIFY_EXPR)
authorRichard Guenther <rguenther@suse.de>
Mon, 24 Mar 2008 15:08:52 +0000 (15:08 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 24 Mar 2008 15:08:52 +0000 (15:08 +0000)
2008-03-24  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.
* configure: Regenerate.

From-SVN: r133479

gcc/ChangeLog
gcc/configure
gcc/configure.ac
gcc/gimplify.c

index fd9ef6023656f73d54bc049856f0972618793a3a..a1ab32856eb6ec6e7fc2e483d909ca704ffcdfcf 100644 (file)
@@ -1,3 +1,12 @@
+2008-03-24  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.
+       * configure: Regenerate.
+
 2008-03-24  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
        * diagnostic.c (diagnostic_count_diagnostic): Delete.
index 454e71a974dcfc91379498aaf4c98ee749bdaf83..1be527276b97160ff5014b1c733db0e9d3c8729b 100755 (executable)
@@ -6439,7 +6439,7 @@ do
                        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= ;;
+                       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 2b3b4ea8c9c96d2b102c811caada574922997204..b4a1744b0ef3fcbf06547e355f3d9bd8189dd2f4 100644 (file)
@@ -367,7 +367,7 @@ do
                        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= ;;
+                       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 acdfb994960f5f7aa8d05b8361701a614e57cf4f..4b084e445a8140a186310b786933ac51e04a031b 100644 (file)
@@ -3599,7 +3599,8 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, tree *pre_p,
             references somehow.  */
          tree init = TARGET_EXPR_INITIAL (*from_p);
 
-         if (!VOID_TYPE_P (TREE_TYPE (init)))
+         if (init
+             && !VOID_TYPE_P (TREE_TYPE (init)))
            {
              *from_p = init;
              ret = GS_OK;
@@ -3870,6 +3871,17 @@ gimplify_modify_expr (tree *expr_p, tree *pre_p, tree *post_p, bool want_value)
              || 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);