diff options
author | Andre Vehreschild <vehre@gcc.gnu.org> | 2015-12-29 14:20:37 +0100 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2015-12-29 14:20:37 +0100 |
commit | 1c645536272780edf11eacc98bf2fa014f8c1489 (patch) | |
tree | 5b56e6b444300ad8bd312805de4757146582d64c /gcc/fortran | |
parent | 0bf0df50e5a18e7b707ba0091cb86e1bd388d4b3 (diff) | |
download | gcc-1c645536272780edf11eacc98bf2fa014f8c1489.zip gcc-1c645536272780edf11eacc98bf2fa014f8c1489.tar.gz gcc-1c645536272780edf11eacc98bf2fa014f8c1489.tar.bz2 |
re PR fortran/69011 ([OOP] ICE in gfc_advance_chain for ALLOCATE with SOURCE)
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.
From-SVN: r231992
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 eeb79d9..668a043 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 72416d4..3c6fae1 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)) |