From 8f266cd9cee99dbd78d45c81e32d5b788104f9e3 Mon Sep 17 00:00:00 2001 From: jakub Date: Sun, 13 Jan 2013 12:33:43 +0000 Subject: [PATCH] PR fortran/55935 * gimple-fold.c (get_symbol_constant_value): Call unshare_expr. (fold_gimple_assign): Don't call unshare_expr here. (fold_ctor_reference): Call unshare_expr. * trans-expr.c (gfc_conv_structure): Call unshare_expr_without_location on the ctor elements. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@195136 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 10 +++++++++- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/trans-expr.c | 2 ++ gcc/gimple-fold.c | 8 ++++---- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4706588ba7..59a16bbdf63 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2013-01-13 Jakub Jelinek + + PR fortran/55935 + * gimple-fold.c (get_symbol_constant_value): Call + unshare_expr. + (fold_gimple_assign): Don't call unshare_expr here. + (fold_ctor_reference): Call unshare_expr. + 2013-01-13 Terry Guo * gcc/Makefile.in (s-mlib): New argument MULTILIB_REUSE. @@ -57,7 +65,7 @@ 2013-01-10 Vladimir Makarov - PR rtl-optimization/pr55672 + PR rtl-optimization/55672 * lra-eliminations.c (mark_not_eliminable): Permit addition with const to be eliminable. diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 92b8083dfce..0f62c2aa54d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2013-01-13 Jakub Jelinek + + PR fortran/55935 + * trans-expr.c (gfc_conv_structure): Call + unshare_expr_without_location on the ctor elements. + 2013-01-13 Paul Thomas PR fortran/54286 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index cad772f1cbd..e3386b18a29 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -6137,6 +6137,7 @@ gfc_conv_structure (gfc_se * se, gfc_expr * expr, int init) gfc_symbol *vtabs; vtabs = cm->initializer->symtree->n.sym; vtab = gfc_build_addr_expr (NULL_TREE, gfc_get_symbol_decl (vtabs)); + vtab = unshare_expr_without_location (vtab); CONSTRUCTOR_APPEND_ELT (v, cm->backend_decl, vtab); } else if (cm->ts.u.derived && strcmp (cm->name, "_size") == 0) @@ -6150,6 +6151,7 @@ gfc_conv_structure (gfc_se * se, gfc_expr * expr, int init) TREE_TYPE (cm->backend_decl), cm->attr.dimension, cm->attr.pointer, cm->attr.proc_pointer); + val = unshare_expr_without_location (val); /* Append it to the constructor list. */ CONSTRUCTOR_APPEND_ELT (v, cm->backend_decl, val); diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 6d38122b595..b9211a9add2 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -202,7 +202,7 @@ get_symbol_constant_value (tree sym) tree val = DECL_INITIAL (sym); if (val) { - val = canonicalize_constructor_val (val, sym); + val = canonicalize_constructor_val (unshare_expr (val), sym); if (val && is_gimple_min_invariant (val)) return val; else @@ -378,7 +378,7 @@ fold_gimple_assign (gimple_stmt_iterator *si) } else if (DECL_P (rhs)) - return unshare_expr (get_symbol_constant_value (rhs)); + return get_symbol_constant_value (rhs); /* If we couldn't fold the RHS, hand over to the generic fold routines. */ @@ -2941,7 +2941,7 @@ fold_ctor_reference (tree type, tree ctor, unsigned HOST_WIDE_INT offset, /* We found the field with exact match. */ if (useless_type_conversion_p (type, TREE_TYPE (ctor)) && !offset) - return canonicalize_constructor_val (ctor, from_decl); + return canonicalize_constructor_val (unshare_expr (ctor), from_decl); /* We are at the end of walk, see if we can view convert the result. */ @@ -2950,7 +2950,7 @@ fold_ctor_reference (tree type, tree ctor, unsigned HOST_WIDE_INT offset, && operand_equal_p (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (ctor)), 0)) { - ret = canonicalize_constructor_val (ctor, from_decl); + ret = canonicalize_constructor_val (unshare_expr (ctor), from_decl); ret = fold_unary (VIEW_CONVERT_EXPR, type, ret); if (ret) STRIP_NOPS (ret); -- 2.11.4.GIT