From: Mikael Morin <mik...@gcc.gnu.org>

Regression-tested on x86_64-pc-linux-gnu.
OK for master?

-- >8 --

The function gfc_conv_descriptor_data_addr generates an address to the
data field of an array descriptor.  It is only used once, and in the
single place where it is used, the address is immediately dereferenced.

This change replaces the single usage with a plain access to the data
field, and removes the function.  As the previous patch removed the
usage of the data field to write to it, the data getter can be used.

gcc/fortran/ChangeLog:

        * trans-array.cc (gfc_conv_descriptor_data_addr): Remove.
        * trans-array.h (gfc_conv_descriptor_data_addr): Remove.
        * trans-decl.cc (gfc_trans_deferred_vars): Use
        gfc_conv_descriptor_data_get.
---
 gcc/fortran/trans-array.cc | 10 ----------
 gcc/fortran/trans-array.h  |  1 -
 gcc/fortran/trans-decl.cc  |  3 +--
 3 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 990aaaffb50..e3b273744bb 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -284,16 +284,6 @@ gfc_conv_descriptor_data_set (stmtblock_t *block, tree 
desc, tree value)
 }
 
 
-/* This provides address access to the data field.  This should only be
-   used by array allocation, passing this on to the runtime.  */
-
-tree
-gfc_conv_descriptor_data_addr (tree desc)
-{
-  tree field = gfc_get_descriptor_field (desc, DATA_FIELD);
-  return gfc_build_addr_expr (NULL_TREE, field);
-}
-
 static tree
 gfc_conv_descriptor_offset (tree desc)
 {
diff --git a/gcc/fortran/trans-array.h b/gcc/fortran/trans-array.h
index 29098fd0ace..345a9752ddd 100644
--- a/gcc/fortran/trans-array.h
+++ b/gcc/fortran/trans-array.h
@@ -173,7 +173,6 @@ void gfc_get_descriptor_offsets_for_info (const_tree, tree 
*, tree *, tree *, tr
                                          tree *, tree *, tree *, tree *);
 
 tree gfc_conv_descriptor_data_get (tree);
-tree gfc_conv_descriptor_data_addr (tree);
 tree gfc_conv_descriptor_offset_get (tree);
 tree gfc_conv_descriptor_span_get (tree);
 tree gfc_conv_descriptor_dtype (tree);
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index e9112116adb..b495f43bbea 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -5148,8 +5148,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, 
gfc_wrapped_block * block)
                      se.descriptor_only = 1;
                      gfc_conv_expr (&se, e);
                      descriptor = se.expr;
-                     se.expr = gfc_conv_descriptor_data_addr (se.expr);
-                     se.expr = build_fold_indirect_ref_loc (input_location, 
se.expr);
+                     se.expr = gfc_conv_descriptor_data_get (se.expr);
                    }
                  gfc_free_expr (e);
 
-- 
2.47.2

Reply via email to