diff options
author | vehre <vehre@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-29 13:20:37 +0000 |
---|---|---|
committer | vehre <vehre@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-12-29 13:20:37 +0000 |
commit | 4136c181c740e45a49cf5f087243eece2b9780de (patch) | |
tree | 5b56e6b444300ad8bd312805de4757146582d64c /gcc/fortran | |
parent | ec55997c7e14b10107deb341e84b56409cea8358 (diff) | |
download | gcc-4136c181c740e45a49cf5f087243eece2b9780de.tar.gz |
gcc/testsuite/ChangeLog:
2015-12-29 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/69011
* gfortran.dg/allocate_with_source_16.f90: New test.
gcc/fortran/ChangeLog:
2015-12-29 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/69011
* trans-stmt.c (gfc_trans_allocate): Unwrap a NOP_EXPR to make sure
the actual type of the source=-expr is used when it is of class type.
Furthermore prevent an ICE.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231992 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fortran/trans-stmt.c | 16 |
2 files changed, 21 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index eeb79d9c814..668a04302db 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2015-12-29 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/69011 + * trans-stmt.c (gfc_trans_allocate): Unwrap a NOP_EXPR to make sure + the actual type of the source=-expr is used when it is of class type. + Furthermore prevent an ICE. + 2015-12-18 Paul Thomas <pault@gcc.gnu.org> PR fortran/68196 diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 72416d48bf4..3c6fae1e9a5 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -5377,7 +5377,20 @@ gfc_trans_allocate (gfc_code * code) if (code->ext.alloc.arr_spec_from_expr3 || code->expr3->rank != 0) gfc_conv_expr_descriptor (&se, code->expr3); else - gfc_conv_expr_reference (&se, code->expr3); + { + gfc_conv_expr_reference (&se, code->expr3); + + /* gfc_conv_expr_reference wraps POINTER_PLUS_EXPR in a + NOP_EXPR, which prevents gfortran from getting the vptr + from the source=-expression. Remove the NOP_EXPR and go + with the POINTER_PLUS_EXPR in this case. */ + if (code->expr3->ts.type == BT_CLASS + && TREE_CODE (se.expr) == NOP_EXPR + && TREE_CODE (TREE_OPERAND (se.expr, 0)) + == POINTER_PLUS_EXPR) + //&& ! GFC_CLASS_TYPE_P (TREE_TYPE (se.expr))) + se.expr = TREE_OPERAND (se.expr, 0); + } /* Create a temp variable only for component refs to prevent having to go through the full deref-chain each time and to simplfy computation of array properties. */ @@ -5494,7 +5507,6 @@ gfc_trans_allocate (gfc_code * code) expr3 may be a temporary array declaration, therefore check for GFC_CLASS_TYPE_P before trying to get the _vptr component. */ if (tmp != NULL_TREE - && TREE_CODE (tmp) != POINTER_PLUS_EXPR && (e3_is == E3_DESC || (GFC_CLASS_TYPE_P (TREE_TYPE (tmp)) && (VAR_P (tmp) || !code->expr3->ref)) |