diff options
author | Janus Weil <janus@gcc.gnu.org> | 2012-10-11 19:52:36 +0200 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2012-10-11 19:52:36 +0200 |
commit | e87924ab48d86b6bf33ae6f33a6e4a0941fca970 (patch) | |
tree | 4bb45a2915d953234dbef2ea935ebf4ab60b699b /gcc/fortran/trans-stmt.c | |
parent | a1dc74f2bf02aa753939071fbd6d82f8db157e66 (diff) | |
download | gcc-e87924ab48d86b6bf33ae6f33a6e4a0941fca970.zip gcc-e87924ab48d86b6bf33ae6f33a6e4a0941fca970.tar.gz gcc-e87924ab48d86b6bf33ae6f33a6e4a0941fca970.tar.bz2 |
re PR fortran/54784 ([OOP] wrong code in polymorphic allocation with SOURCE)
2012-10-11 Janus Weil <janus@gcc.gnu.org>
PR fortran/54784
* trans-stmt.c (gfc_trans_allocate): Correctly determine the reference
to the _data component for polymorphic allocation with SOURCE.
2012-10-11 Janus Weil <janus@gcc.gnu.org>
PR fortran/54784
* gfortran.dg/class_allocate_13.f90: New.
From-SVN: r192374
Diffstat (limited to 'gcc/fortran/trans-stmt.c')
-rw-r--r-- | gcc/fortran/trans-stmt.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 204f069..bfcb686 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -5130,7 +5130,7 @@ gfc_trans_allocate (gfc_code * code) gfc_actual_arglist *actual; gfc_expr *ppc; gfc_code *ppc_code; - gfc_ref *dataref; + gfc_ref *ref, *dataref; /* Do a polymorphic deep copy. */ actual = gfc_get_actual_arglist (); @@ -5142,13 +5142,15 @@ gfc_trans_allocate (gfc_code * code) actual->next->expr->ts.type = BT_CLASS; gfc_add_data_component (actual->next->expr); - dataref = actual->next->expr->ref; + dataref = NULL; /* Make sure we go up through the reference chain to the _data reference, where the arrayspec is found. */ - while (dataref->next && dataref->next->type != REF_ARRAY) - dataref = dataref->next; + for (ref = actual->next->expr->ref; ref; ref = ref->next) + if (ref->type == REF_COMPONENT + && strcmp (ref->u.c.component->name, "_data") == 0) + dataref = ref; - if (dataref->u.c.component->as) + if (dataref && dataref->u.c.component->as) { int dim; gfc_expr *temp; |