aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index bdb64ea..7f1dc4a 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4725,10 +4725,22 @@ gimplify_addr_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
if (TREE_CODE (op0) == INDIRECT_REF)
goto do_indirect_ref;
+ mark_addressable (TREE_OPERAND (expr, 0));
+
+ /* The FEs may end up building ADDR_EXPRs early on a decl with
+ an incomplete type. Re-build ADDR_EXPRs in canonical form
+ here. */
+ if (!types_compatible_p (TREE_TYPE (op0), TREE_TYPE (TREE_TYPE (expr))))
+ *expr_p = build_fold_addr_expr (op0);
+
/* Make sure TREE_CONSTANT and TREE_SIDE_EFFECTS are set properly. */
- recompute_tree_invariant_for_addr_expr (expr);
+ recompute_tree_invariant_for_addr_expr (*expr_p);
+
+ /* If we re-built the ADDR_EXPR add a conversion to the original type
+ if required. */
+ if (!useless_type_conversion_p (TREE_TYPE (expr), TREE_TYPE (*expr_p)))
+ *expr_p = fold_convert (TREE_TYPE (expr), *expr_p);
- mark_addressable (TREE_OPERAND (expr, 0));
break;
}