aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-03-24 15:08:52 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-03-24 15:08:52 +0000
commit1b24a790e0f4443ebbe19977f66378f60b059269 (patch)
treea7b12b2f030414354125acf1f0fff3ea55cec094 /gcc/gimplify.c
parent52249a2e3f3d67b8a86ad232428005c449b77a3e (diff)
downloadgcc-1b24a790e0f4443ebbe19977f66378f60b059269.zip
gcc-1b24a790e0f4443ebbe19977f66378f60b059269.tar.gz
gcc-1b24a790e0f4443ebbe19977f66378f60b059269.tar.bz2
re PR c/22371 (C front-end produces mis-match types in MODIFY_EXPR)
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
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index acdfb99..4b084e4 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -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);