aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2019-05-10 07:59:42 +0000
committerPaul Thomas <pault@gcc.gnu.org>2019-05-10 07:59:42 +0000
commit0a52429609a9570149af903c231c25f17da79b15 (patch)
tree5949919936e24cc45ea5df3794892250570d0ba2 /gcc/fortran/trans-array.c
parente965aaf6027f52020992279f59ed166805c33d55 (diff)
downloadgcc-0a52429609a9570149af903c231c25f17da79b15.zip
gcc-0a52429609a9570149af903c231c25f17da79b15.tar.gz
gcc-0a52429609a9570149af903c231c25f17da79b15.tar.bz2
re PR fortran/90093 (Extended C interop: optional argument incorrectly identified as PRESENT)
2019-05-10 Paul Thomas <pault@gcc.gnu.org> PR fortran/90093 * trans-decl.c (convert_CFI_desc): Test that the dummy is present before doing any of the conversions. PR fortran/90352 * decl.c (gfc_verify_c_interop_param): Restore the error for charlen > 1 actual arguments passed to bind(C) procs. Clean up trailing white space. PR fortran/90355 * trans-array.c (gfc_trans_create_temp_array): Set the 'span' field to the element length for all types. (gfc_conv_expr_descriptor): The force_no_tmp flag is used to prevent temporary creation, especially for substrings. * trans-decl.c (gfc_trans_deferred_vars): Rather than assert that the backend decl for the string length is non-null, use it as a condition before calling gfc_trans_vla_type_sizes. * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): 'force_no_tmp' is set before calling gfc_conv_expr_descriptor. * trans.c (get_array_span): Move the code for extracting 'span' from gfc_build_array_ref to this function. This is specific to descriptors that are component and indirect references. * trans.h : Add the force_no_tmp flag bitfield to gfc_se. 2019-05-10 Paul Thomas <pault@gcc.gnu.org> PR fortran/90093 * gfortran.dg/ISO_Fortran_binding_12.f90: New test. * gfortran.dg/ISO_Fortran_binding_12.c: Supplementary code. PR fortran/90352 * gfortran.dg/iso_c_binding_char_1.f90: New test. PR fortran/90355 * gfortran.dg/ISO_Fortran_binding_4.f90: Add 'substr' to test the direct passing of substrings as descriptors to bind(C). * gfortran.dg/assign_10.f90: Increase the tree_dump count of 'atmp' to account for the setting of the 'span' field. * gfortran.dg/transpose_optimization_2.f90: Ditto. From-SVN: r271057
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 55879af..8a0de61 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -1239,6 +1239,7 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss,
tree nelem;
tree cond;
tree or_expr;
+ tree elemsize;
tree class_expr = NULL_TREE;
int n, dim, tmp_dim;
int total_dim = 0;
@@ -1333,15 +1334,6 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss,
tmp = gfc_conv_descriptor_dtype (desc);
gfc_add_modify (pre, tmp, gfc_get_dtype (TREE_TYPE (desc)));
- /* Also set the span for derived types, since they can be used in
- component references to arrays of this type. */
- if (TREE_CODE (eltype) == RECORD_TYPE)
- {
- tmp = TYPE_SIZE_UNIT (eltype);
- tmp = fold_convert (gfc_array_index_type, tmp);
- gfc_conv_descriptor_span_set (pre, desc, tmp);
- }
-
/*
Fill in the bounds and stride. This is a packed array, so:
@@ -1413,22 +1405,21 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss,
}
}
+ if (class_expr == NULL_TREE)
+ elemsize = fold_convert (gfc_array_index_type,
+ TYPE_SIZE_UNIT (gfc_get_element_type (type)));
+ else
+ elemsize = gfc_class_vtab_size_get (class_expr);
+
/* Get the size of the array. */
if (size && !callee_alloc)
{
- tree elemsize;
/* If or_expr is true, then the extent in at least one
dimension is zero and the size is set to zero. */
size = fold_build3_loc (input_location, COND_EXPR, gfc_array_index_type,
or_expr, gfc_index_zero_node, size);
nelem = size;
- if (class_expr == NULL_TREE)
- elemsize = fold_convert (gfc_array_index_type,
- TYPE_SIZE_UNIT (gfc_get_element_type (type)));
- else
- elemsize = gfc_class_vtab_size_get (class_expr);
-
size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
size, elemsize);
}
@@ -1438,6 +1429,10 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss,
size = NULL_TREE;
}
+ /* Set the span. */
+ tmp = fold_convert (gfc_array_index_type, elemsize);
+ gfc_conv_descriptor_span_set (pre, desc, tmp);
+
gfc_trans_allocate_array_storage (pre, post, info, size, nelem, initial,
dynamic, dealloc);
@@ -7248,6 +7243,8 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr)
if (se->force_tmp)
need_tmp = 1;
+ else if (se->force_no_tmp)
+ need_tmp = 0;
if (need_tmp)
full = 0;