diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2016-06-02 17:44:59 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2016-06-02 17:44:59 +0000 |
commit | fc36f1854704dca49260319d40118ddf0b2c128b (patch) | |
tree | 7578839085b97bb96c1851b48ee6c9d8003988d1 | |
parent | 8cf97c563f66385c7d3d580fb7d8b154899b255c (diff) |
2016-06-02 Paul Thomas <pault@gcc.gnu.org>
PR fortran/70350
Backport from trunk.
* trans-expr.c (gfc_trans_assignment_1): Exclude initialization
assignments from check on assignment of scalars to unassigned
arrays and correct wrong code within the corresponding block.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-5-branch@237043 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/fortran/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.c | 20 |
2 files changed, 20 insertions, 8 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1b5fc3dd6c8..8e96384e6a6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2016-06-02 Paul Thomas <pault@gcc.gnu.org> + + Backport from trunk. + PR fortran/70350 + * trans-expr.c (gfc_trans_assignment_1): Exclude initialization + assignments from check on assignment of scalars to unassigned + arrays and correct wrong code within the corresponding block. + 2016-05-26 Jerry DeLisle <jvdelisle@gcc.gnu.org> Backport from trunk. diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 642ce26d02b..6f0bf6148b6 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -9125,8 +9125,9 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, } else { - gfc_conv_expr (&lse, expr1); + gfc_conv_expr (&lse, expr1); if (gfc_option.rtcheck & GFC_RTCHECK_MEM + && !init_flag && gfc_expr_attr (expr1).allocatable && expr1->rank && !expr2->rank) @@ -9134,14 +9135,17 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, tree cond; const char* msg; - tmp = expr1->symtree->n.sym->backend_decl; - if (POINTER_TYPE_P (TREE_TYPE (tmp))) - tmp = build_fold_indirect_ref_loc (input_location, tmp); + /* We should only get array references here. */ + gcc_assert (TREE_CODE (lse.expr) == POINTER_PLUS_EXPR + || TREE_CODE (lse.expr) == ARRAY_REF); - if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (tmp))) - tmp = gfc_conv_descriptor_data_get (tmp); - else - tmp = TREE_OPERAND (lse.expr, 0); + /* 'tmp' is either the pointer to the array(POINTER_PLUS_EXPR) + or the array itself(ARRAY_REF). */ + tmp = TREE_OPERAND (lse.expr, 0); + + /* Provide the address of the array. */ + if (TREE_CODE (lse.expr) == ARRAY_REF) + tmp = gfc_build_addr_expr (NULL_TREE, tmp); cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, tmp, build_int_cst (TREE_TYPE (tmp), 0)); |