diff options
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index c4df4eb..ea4cf8c 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -5333,7 +5333,7 @@ gfc_array_init_size (tree descriptor, int rank, int corank, tree * poffset, gfc_expr ** lower, gfc_expr ** upper, stmtblock_t * pblock, stmtblock_t * descriptor_block, tree * overflow, tree expr3_elem_size, tree *nelems, gfc_expr *expr3, - tree expr3_desc, bool e3_is_array_constr, gfc_expr *expr) + tree expr3_desc, bool e3_has_nodescriptor, gfc_expr *expr) { tree type; tree tmp; @@ -5412,10 +5412,11 @@ gfc_array_init_size (tree descriptor, int rank, int corank, tree * poffset, gfc_init_se (&se, NULL); if (expr3_desc != NULL_TREE) { - if (e3_is_array_constr) - /* The lbound of a constant array [] starts at zero, but when - allocating it, the standard expects the array to start at - one. */ + if (e3_has_nodescriptor) + /* The lbound of nondescriptor arrays like array constructors, + nonallocatable/nonpointer function results/variables, + start at zero, but when allocating it, the standard expects + the array to start at one. */ se.expr = gfc_index_one_node; else se.expr = gfc_conv_descriptor_lbound_get (expr3_desc, @@ -5451,12 +5452,13 @@ gfc_array_init_size (tree descriptor, int rank, int corank, tree * poffset, gfc_init_se (&se, NULL); if (expr3_desc != NULL_TREE) { - if (e3_is_array_constr) + if (e3_has_nodescriptor) { - /* The lbound of a constant array [] starts at zero, but when - allocating it, the standard expects the array to start at - one. Therefore fix the upper bound to be - (desc.ubound - desc.lbound)+ 1. */ + /* The lbound of nondescriptor arrays like array constructors, + nonallocatable/nonpointer function results/variables, + start at zero, but when allocating it, the standard expects + the array to start at one. Therefore fix the upper bound to be + (desc.ubound - desc.lbound) + 1. */ tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, gfc_conv_descriptor_ubound_get ( @@ -5684,7 +5686,7 @@ bool gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg, tree errlen, tree label_finish, tree expr3_elem_size, tree *nelems, gfc_expr *expr3, tree e3_arr_desc, - bool e3_is_array_constr) + bool e3_has_nodescriptor) { tree tmp; tree pointer; @@ -5813,7 +5815,7 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg, &offset, lower, upper, &se->pre, &set_descriptor_block, &overflow, expr3_elem_size, nelems, expr3, e3_arr_desc, - e3_is_array_constr, expr); + e3_has_nodescriptor, expr); if (dimension) { |