aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorTobias Burnus <burnus@gcc.gnu.org>2019-10-31 11:12:55 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2019-10-31 11:12:55 +0100
commitfc5a970817ad432e06cf22613ac5bd3e85c0e081 (patch)
tree9c54878c62654d99053197728ae36370287bccb4 /gcc/fortran
parent9ba66bf5b9c69e0e2bcd1b2ab88160bf9b2aa417 (diff)
downloadgcc-fc5a970817ad432e06cf22613ac5bd3e85c0e081.zip
gcc-fc5a970817ad432e06cf22613ac5bd3e85c0e081.tar.gz
gcc-fc5a970817ad432e06cf22613ac5bd3e85c0e081.tar.bz2
Fortran] PR92284 – gfc_desc_to_cfi_desc fixes
gcc/fortran/ PR fortran/92284. * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Free CFI descriptor at the end; partial revised revert of Rev. 277502. libgfortran/ PR fortran/92284. * runtime/ISO_Fortran_binding.c (gfc_desc_to_cfi_desc): gcc/testsuite/ PR fortran/92284. * gfortran.dg/bind-c-intent-out.f90: Update expected dump; extend comment. * gfortran.dg/bind_c_array_params_3.f90: New. * gfortran.dg/bind_c_array_params_3_aux.c: New. From-SVN: r277663
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/trans-expr.c12
2 files changed, 14 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index e177168..6cd05d1 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,11 @@
2019-10-31 Tobias Burnus <tobias@codesourcery.com>
+ PR fortran/92284.
+ * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Free CFI descriptor
+ at the end; partial revised revert of Rev. 277502.
+
+2019-10-31 Tobias Burnus <tobias@codesourcery.com>
+
PR fortran/92277
* trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Fix DECL_ARTIFICIAL
checking.
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 381e314..f800faa 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -5306,13 +5306,13 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
/* Now pass the gfc_descriptor by reference. */
parmse->expr = gfc_build_addr_expr (NULL_TREE, parmse->expr);
- /* Variables to point to the gfc and CFI descriptors. */
+ /* Variables to point to the gfc and CFI descriptors; cfi = NULL implies
+ that the CFI descriptor is allocated by the gfor_fndecl_gfc_to_cfi call. */
gfc_desc_ptr = parmse->expr;
cfi_desc_ptr = gfc_create_var (pvoid_type_node, "cfi");
- gfc_add_modify (&parmse->pre, cfi_desc_ptr,
- build_int_cst (pvoid_type_node, 0));
+ gfc_add_modify (&parmse->pre, cfi_desc_ptr, null_pointer_node);
- /* Allocate the CFI descriptor and fill the fields. */
+ /* Allocate the CFI descriptor itself and fill the fields. */
tmp = gfc_build_addr_expr (NULL_TREE, cfi_desc_ptr);
tmp = build_call_expr_loc (input_location,
gfor_fndecl_gfc_to_cfi, 2, tmp, gfc_desc_ptr);
@@ -5327,6 +5327,10 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
/* The CFI descriptor is passed to the bind_C procedure. */
parmse->expr = cfi_desc_ptr;
+ /* Free the CFI descriptor. */
+ tmp = gfc_call_free (cfi_desc_ptr);
+ gfc_prepend_expr_to_block (&parmse->post, tmp);
+
/* Transfer values back to gfc descriptor. */
tmp = gfc_build_addr_expr (NULL_TREE, parmse->expr);
tmp = build_call_expr_loc (input_location,