diff options
Diffstat (limited to 'gcc-4.8/gcc/fortran/trans-stmt.c')
-rw-r--r-- | gcc-4.8/gcc/fortran/trans-stmt.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc-4.8/gcc/fortran/trans-stmt.c b/gcc-4.8/gcc/fortran/trans-stmt.c index 430b10e37..1d8588d60 100644 --- a/gcc-4.8/gcc/fortran/trans-stmt.c +++ b/gcc-4.8/gcc/fortran/trans-stmt.c @@ -5104,10 +5104,49 @@ gfc_trans_allocate (gfc_code * code) { gfc_expr *lhs, *rhs; gfc_se lse; + gfc_ref *ref, *class_ref, *tail; + + /* Find the last class reference. */ + class_ref = NULL; + for (ref = e->ref; ref; ref = ref->next) + { + if (ref->type == REF_COMPONENT + && ref->u.c.component->ts.type == BT_CLASS) + class_ref = ref; + + if (ref->next == NULL) + break; + } + + /* Remove and store all subsequent references after the + CLASS reference. */ + if (class_ref) + { + tail = class_ref->next; + class_ref->next = NULL; + } + else + { + tail = e->ref; + e->ref = NULL; + } lhs = gfc_expr_to_initialize (e); gfc_add_vptr_component (lhs); + /* Remove the _vptr component and restore the original tail + references. */ + if (class_ref) + { + gfc_free_ref_list (class_ref->next); + class_ref->next = tail; + } + else + { + gfc_free_ref_list (e->ref); + e->ref = tail; + } + if (class_expr != NULL_TREE) { /* Polymorphic SOURCE: VPTR must be determined at run time. */ |