aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.c
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2019-10-31 10:06:19 +0000
committerTobias Burnus <burnus@gcc.gnu.org>2019-10-31 11:06:19 +0100
commit6409a3c0369313f604b349ffc53efd78d873f790 (patch)
tree803e6e75e13969bc7585fbf7a45df074fea510a4 /gcc/fortran/trans-expr.c
parent6773658a809fbebcdb68483cb929207150ac7e5f (diff)
downloadgcc-6409a3c0369313f604b349ffc53efd78d873f790.zip
gcc-6409a3c0369313f604b349ffc53efd78d873f790.tar.gz
gcc-6409a3c0369313f604b349ffc53efd78d873f790.tar.bz2
Fortran] PR92277 - Fix assumed-rank array with bind(C)
gcc/fortran/ PR fortran/92277 * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Fix DECL_ARTIFICIAL checking. gcc/testsuite/ PR fortran/92277 * fortran.dg/pr92277.f90: New. From-SVN: r277661
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r--gcc/fortran/trans-expr.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 7eba1bb..381e314 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -5239,6 +5239,9 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
if (POINTER_TYPE_P (TREE_TYPE (parmse->expr)))
parmse->expr = build_fold_indirect_ref_loc (input_location,
parmse->expr);
+ bool is_artificial = (INDIRECT_REF_P (parmse->expr)
+ ? DECL_ARTIFICIAL (TREE_OPERAND (parmse->expr, 0))
+ : DECL_ARTIFICIAL (parmse->expr));
/* Unallocated allocatable arrays and unassociated pointer arrays
need their dtype setting if they are argument associated with
@@ -5258,7 +5261,7 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
type = e->ts.type != BT_ASSUMED ? gfc_typenode_for_spec (&e->ts) :
NULL_TREE;
- if (type && DECL_ARTIFICIAL (parmse->expr)
+ if (type && is_artificial
&& type != gfc_get_element_type (TREE_TYPE (parmse->expr)))
{
/* Obtain the offset to the data. */
@@ -5271,7 +5274,7 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
gfc_get_dtype_rank_type (e->rank, type));
}
else if (type == NULL_TREE
- || (!is_subref_array (e) && !DECL_ARTIFICIAL (parmse->expr)))
+ || (!is_subref_array (e) && !is_artificial))
{
/* Make sure that the span is set for expressions where it
might not have been done already. */