summaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-intrinsic.c
diff options
context:
space:
mode:
authorvehre <vehre@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-07 10:58:46 +0000
committervehre <vehre@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-07 10:58:46 +0000
commit10c26e1edbacf092430371adc54be79ea0275dec (patch)
tree7ba26ec840e54efa14fcbb0d612f3825a8ddaa14 /gcc/fortran/trans-intrinsic.c
parent2be65b687d9638d4c83d355c0772e5a18f8eefbf (diff)
downloadgcc-10c26e1edbacf092430371adc54be79ea0275dec.tar.gz
gcc/fortran/ChangeLog:
2015-10-07 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/65889 * trans-intrinsic.c (gfc_conv_intrinsic_sizeof): Handle pointer to and on stack class objects as sizeof parameter. gcc/testsuite/ChangeLog: 2015-10-07 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/65889 * gfortran.dg/sizeof_5.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228566 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-intrinsic.c')
-rw-r--r--gcc/fortran/trans-intrinsic.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 35052bebb8e..ac61c096a99 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -5937,11 +5937,16 @@ gfc_conv_intrinsic_sizeof (gfc_se *se, gfc_expr *expr)
}
else if (arg->ts.type == BT_CLASS)
{
- /* For deferred length arrays, conv_expr_descriptor returns an
- indirect_ref to the component. */
+ /* Conv_expr_descriptor returns a component_ref to _data component of the
+ class object. The class object may be a non-pointer object, e.g.
+ located on the stack, or a memory location pointed to, e.g. a
+ parameter, i.e., an indirect_ref. */
if (arg->rank < 0
|| (arg->rank > 0 && !VAR_P (argse.expr)
- && GFC_DECL_CLASS (TREE_OPERAND (argse.expr, 0))))
+ && ((INDIRECT_REF_P (TREE_OPERAND (argse.expr, 0))
+ && GFC_DECL_CLASS (TREE_OPERAND (
+ TREE_OPERAND (argse.expr, 0), 0)))
+ || GFC_DECL_CLASS (TREE_OPERAND (argse.expr, 0)))))
byte_size = gfc_class_vtab_size_get (TREE_OPERAND (argse.expr, 0));
else if (arg->rank > 0)
/* The scalarizer added an additional temp. To get the class' vptr