diff options
author | Andre Vehreschild <vehre@gcc.gnu.org> | 2016-11-16 14:45:29 +0100 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2016-11-16 14:45:29 +0100 |
commit | dc9e0b66b22fa73f396645d7efd8b73649f2fe6b (patch) | |
tree | e7b4f5f3869d8e0b144aa416e4efbff8d47e19d5 /gcc/fortran/class.c | |
parent | 45a9968b378d54ced8f742e1ff8b01c9378b339c (diff) | |
download | gcc-dc9e0b66b22fa73f396645d7efd8b73649f2fe6b.zip gcc-dc9e0b66b22fa73f396645d7efd8b73649f2fe6b.tar.gz gcc-dc9e0b66b22fa73f396645d7efd8b73649f2fe6b.tar.bz2 |
re PR fortran/78356 ([OOP] segfault allocating polymorphic variable with polymorphic component with allocatable component)
gcc/fortran/ChangeLog:
2016-11-16 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/78356
* class.c (gfc_is_class_scalar_expr): Prevent taking an array ref for
a component ref.
* trans-expr.c (gfc_trans_assignment_1): Ensure a reference to the
object to copy is generated, when assigning class objects.
gcc/testsuite/ChangeLog:
2016-11-16 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/78356
* gfortran.dg/class_allocate_23.f08: New test.
From-SVN: r242490
Diffstat (limited to 'gcc/fortran/class.c')
-rw-r--r-- | gcc/fortran/class.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index b42ec40..9db86b4 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -378,7 +378,8 @@ gfc_is_class_scalar_expr (gfc_expr *e) && CLASS_DATA (e->symtree->n.sym) && !CLASS_DATA (e->symtree->n.sym)->attr.dimension && (e->ref == NULL - || (strcmp (e->ref->u.c.component->name, "_data") == 0 + || (e->ref->type == REF_COMPONENT + && strcmp (e->ref->u.c.component->name, "_data") == 0 && e->ref->next == NULL))) return true; @@ -390,7 +391,8 @@ gfc_is_class_scalar_expr (gfc_expr *e) && CLASS_DATA (ref->u.c.component) && !CLASS_DATA (ref->u.c.component)->attr.dimension && (ref->next == NULL - || (strcmp (ref->next->u.c.component->name, "_data") == 0 + || (ref->next->type == REF_COMPONENT + && strcmp (ref->next->u.c.component->name, "_data") == 0 && ref->next->next == NULL))) return true; } |