aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans.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.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.c')
-rw-r--r--gcc/fortran/trans.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index 022ceb9..e7844c9 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -290,6 +290,16 @@ get_array_span (tree type, tree decl)
{
tree span;
+ /* Component references are guaranteed to have a reliable value for
+ 'span'. Likewise indirect references since they emerge from the
+ conversion of a CFI descriptor or the hidden dummy descriptor. */
+ if (TREE_CODE (decl) == COMPONENT_REF
+ && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl)))
+ return gfc_conv_descriptor_span_get (decl);
+ else if (TREE_CODE (decl) == INDIRECT_REF
+ && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl)))
+ return gfc_conv_descriptor_span_get (decl);
+
/* Return the span for deferred character length array references. */
if (type && TREE_CODE (type) == ARRAY_TYPE
&& TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != NULL_TREE
@@ -352,9 +362,6 @@ get_array_span (tree type, tree decl)
else
span = NULL_TREE;
}
- else if (TREE_CODE (decl) == INDIRECT_REF
- && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl)))
- span = gfc_conv_descriptor_span_get (decl);
else
span = NULL_TREE;
@@ -399,12 +406,7 @@ gfc_build_array_ref (tree base, tree offset, tree decl, tree vptr)
if (vptr)
span = gfc_vptr_size_get (vptr);
else if (decl)
- {
- if (TREE_CODE (decl) == COMPONENT_REF)
- span = gfc_conv_descriptor_span_get (decl);
- else
- span = get_array_span (type, decl);
- }
+ span = get_array_span (type, decl);
/* If a non-null span has been generated reference the element with
pointer arithmetic. */