diff options
author | Andre Vehreschild <vehre@gcc.gnu.org> | 2015-10-25 13:28:57 +0100 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2015-10-25 13:28:57 +0100 |
commit | b8ac4f3b22887143eec7e51497e95ff7301631df (patch) | |
tree | 2bf4d8a03141715e2374e096c4386e41791de20e /gcc/fortran/trans-array.c | |
parent | f63df1373912b1c8b65e34e064594c0eb15153f9 (diff) | |
download | gcc-b8ac4f3b22887143eec7e51497e95ff7301631df.zip gcc-b8ac4f3b22887143eec7e51497e95ff7301631df.tar.gz gcc-b8ac4f3b22887143eec7e51497e95ff7301631df.tar.bz2 |
re PR fortran/66927 (ICE in gfc_conf_procedure_call)
gcc/fortran/ChangeLog:
2015-10-25 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/66927
PR fortran/67044
* trans-array.c (build_array_ref): Modified call to
gfc_get_class_array_ref to adhere to new interface.
(gfc_conv_expr_descriptor): For one-based arrays that
are filled by a loop starting at one the start index of the
source array has to be mangled into the offset.
* trans-expr.c (gfc_get_class_array_ref): When the tree to get
the _data component is present already, add a way to supply it.
(gfc_copy_class_to_class): Allow to copy to a derived type also.
* trans-stmt.c (gfc_trans_allocate): Do not conv_expr_descriptor
for functions returning a class or derived object. Get the
reference instead.
* trans.h: Interface change of gfc_get_class_array_ref.
gcc/testsuite/ChangeLog:
2015-10-25 Andre Vehreschild <vehre@gmx.de>
PR fortran/66927
PR fortran/67044
* gfortran.dg/allocate_with_source_10.f08: New test.
* gfortran.dg/allocate_with_source_11.f08: New test.
* gfortran.dg/class_array_15.f03: Changed count of expected
_builtin_frees to 11. One step of temporaries is spared, therefore
the allocatable component of that temporary is not to be freeed.
From-SVN: r229294
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index e1d7f78..45c18a5 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -3250,7 +3250,7 @@ build_array_ref (tree desc, tree offset, tree decl, tree vptr) { type = gfc_get_element_type (type); tmp = TREE_OPERAND (cdecl, 0); - tmp = gfc_get_class_array_ref (offset, tmp); + tmp = gfc_get_class_array_ref (offset, tmp, NULL_TREE); tmp = fold_convert (build_pointer_type (type), tmp); tmp = build_fold_indirect_ref_loc (input_location, tmp); return tmp; @@ -7107,9 +7107,20 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) } else if (GFC_ARRAY_TYPE_P (TREE_TYPE (desc)) || se->use_offset) { + bool toonebased; tmp = gfc_conv_array_lbound (desc, n); + toonebased = integer_onep (tmp); + // lb(arr) - from (- start + 1) tmp = fold_build2_loc (input_location, MINUS_EXPR, TREE_TYPE (base), tmp, from); + if (onebased && toonebased) + { + tmp = fold_build2_loc (input_location, MINUS_EXPR, + TREE_TYPE (base), tmp, start); + tmp = fold_build2_loc (input_location, PLUS_EXPR, + TREE_TYPE (base), tmp, + gfc_index_one_node); + } tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (base), tmp, gfc_conv_array_stride (desc, n)); @@ -7183,12 +7194,13 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr) /* For class arrays add the class tree into the saved descriptor to enable getting of _vptr and the like. */ if (expr->expr_type == EXPR_VARIABLE && VAR_P (desc) - && IS_CLASS_ARRAY (expr->symtree->n.sym) - && DECL_LANG_SPECIFIC (expr->symtree->n.sym->backend_decl)) + && IS_CLASS_ARRAY (expr->symtree->n.sym)) { gfc_allocate_lang_decl (desc); GFC_DECL_SAVED_DESCRIPTOR (desc) = - GFC_DECL_SAVED_DESCRIPTOR (expr->symtree->n.sym->backend_decl); + DECL_LANG_SPECIFIC (expr->symtree->n.sym->backend_decl) ? + GFC_DECL_SAVED_DESCRIPTOR (expr->symtree->n.sym->backend_decl) + : expr->symtree->n.sym->backend_decl; } if (!se->direct_byref || se->byref_noassign) { |