aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-types.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2018-05-13 17:01:16 +0000
committerPaul Thomas <pault@gcc.gnu.org>2018-05-13 17:01:16 +0000
commitf094a21f31a0ada105b5c8e7fe85f05c225fd3f4 (patch)
tree9da4b0c241f1ee86401dc99456230cdcccf0a722 /gcc/fortran/trans-types.c
parent798a67a4ce57b295d568a8548c0319258a805c23 (diff)
downloadgcc-f094a21f31a0ada105b5c8e7fe85f05c225fd3f4.zip
gcc-f094a21f31a0ada105b5c8e7fe85f05c225fd3f4.tar.gz
gcc-f094a21f31a0ada105b5c8e7fe85f05c225fd3f4.tar.bz2
re PR fortran/85742 (sizeof allocatable arrays returning wrong value)
2018-05-13 Paul Thomas <pault@gcc.gnu.org> PR fortran/85742 * trans-types.c (gfc_get_dtype_rank_type): Reorder evaluation of 'size'. If the element type is a pointer use the size of the TREE_TYPE of the type, unless it is VOID_TYPE. In this latter case, set the size to zero. 2018-05-13 Paul Thomas <pault@gcc.gnu.org> PR fortran/85742 * gfortran.dg/assumed_type_9.f90 : New test. From-SVN: r260211
Diffstat (limited to 'gcc/fortran/trans-types.c')
-rw-r--r--gcc/fortran/trans-types.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 7ff27a3..f50eb0a 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -1518,6 +1518,8 @@ gfc_get_dtype_rank_type (int rank, tree etype)
tree field;
vec<constructor_elt, va_gc> *v = NULL;
+ size = TYPE_SIZE_UNIT (etype);
+
switch (TREE_CODE (etype))
{
case INTEGER_TYPE:
@@ -1546,22 +1548,24 @@ gfc_get_dtype_rank_type (int rank, tree etype)
/* We will never have arrays of arrays. */
case ARRAY_TYPE:
n = BT_CHARACTER;
+ if (size == NULL_TREE)
+ size = TYPE_SIZE_UNIT (TREE_TYPE (etype));
break;
case POINTER_TYPE:
n = BT_ASSUMED;
+ if (TREE_CODE (TREE_TYPE (etype)) != VOID_TYPE)
+ size = TYPE_SIZE_UNIT (TREE_TYPE (etype));
+ else
+ size = build_int_cst (size_type_node, 0);
break;
default:
/* TODO: Don't do dtype for temporary descriptorless arrays. */
- /* We can strange array types for temporary arrays. */
+ /* We can encounter strange array types for temporary arrays. */
return gfc_index_zero_node;
}
- size = TYPE_SIZE_UNIT (etype);
- if (n == BT_CHARACTER && size == NULL_TREE)
- size = TYPE_SIZE_UNIT (TREE_TYPE (etype));
-
tmp = get_dtype_type_node ();
field = gfc_advance_chain (TYPE_FIELDS (tmp),
GFC_DTYPE_ELEM_LEN);