aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2018-03-01 08:56:31 +0000
committerPaul Thomas <pault@gcc.gnu.org>2018-03-01 08:56:31 +0000
commitb120c8b207d33f00b34fad9256740d6483839d2b (patch)
treedb01cf2ce08c07b6688a46595701b58ab7d140b0 /gcc/fortran/trans-array.c
parent2514222436ea242510fd6457c0d42e60af4d3535 (diff)
downloadgcc-b120c8b207d33f00b34fad9256740d6483839d2b.zip
gcc-b120c8b207d33f00b34fad9256740d6483839d2b.tar.gz
gcc-b120c8b207d33f00b34fad9256740d6483839d2b.tar.bz2
re PR fortran/84538 (Array of derived type elements incorrectly accessed in function)
2018-03-01 Paul Thomas <pault@gcc.gnu.org> PR fortran/84538 * class.c (class_array_ref_detected): Remove the condition that there be no reference after the array reference. (find_intrinsic_vtab): Remove excess whitespace. * trans-array.c (gfc_conv_scalarized_array_ref): Rename 'tmp' as 'base and call build_class_array_ref earlier. 2018-03-01 Paul Thomas <pault@gcc.gnu.org> PR fortran/84538 * gfortran.dg/class_array_23.f03: New test. From-SVN: r258097
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index e321db3..171cebd 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -3376,7 +3376,7 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar)
gfc_array_info *info;
tree decl = NULL_TREE;
tree index;
- tree tmp;
+ tree base;
gfc_ss *ss;
gfc_expr *expr;
int n;
@@ -3396,6 +3396,12 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar)
index = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
index, info->offset);
+ base = build_fold_indirect_ref_loc (input_location, info->data);
+
+ /* Use the vptr 'size' field to access the element of a class array. */
+ if (build_class_array_ref (se, base, index))
+ return;
+
if (expr && ((is_subref_array (expr)
&& GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (info->descriptor)))
|| (expr->ts.deferred && (expr->expr_type == EXPR_VARIABLE
@@ -3420,14 +3426,7 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar)
decl = info->descriptor;
}
- tmp = build_fold_indirect_ref_loc (input_location, info->data);
-
- /* Use the vptr 'size' field to access a class the element of a class
- array. */
- if (build_class_array_ref (se, tmp, index))
- return;
-
- se->expr = gfc_build_array_ref (tmp, index, decl);
+ se->expr = gfc_build_array_ref (base, index, decl);
}