diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2019-02-24 22:49:47 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2019-02-24 22:49:47 +0000 |
commit | 4afe82523f19171fb0a67fab5ec80c8f645db517 (patch) | |
tree | 15d890f60a78e20ebf11013e77630181130508cf /gcc/fortran/trans-expr.c | |
parent | 28d08ad204087e2c9e979d8dc94daba7ac4c63a3 (diff) | |
download | gcc-4afe82523f19171fb0a67fab5ec80c8f645db517.zip gcc-4afe82523f19171fb0a67fab5ec80c8f645db517.tar.gz gcc-4afe82523f19171fb0a67fab5ec80c8f645db517.tar.bz2 |
re PR fortran/89174 (Allocation segfault with CLASS(*) MOLD)
2019-02-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/89174
* trans-expr.c (gfc_find_and_cut_at_last_class_ref): Add is_mold
to garguments. If we are dealing with a MOLD, call
gfc_expr_to_initialize().
* trans-stmt.c (gfc_trans_allocate): For MOLD, pass is_mold=true
to gfc_find_and_cut_at_last_class_ref.
* trans.h (gfc_find_and_cut_at_last_class_ref): Add optional
argument is_mold with default false.
2019-02-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/89174
* gfortran.dg/allocate_with_mold_3.f90: New test.
From-SVN: r269179
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r-- | gcc/fortran/trans-expr.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index a865cd6..0702713 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -352,7 +352,7 @@ gfc_vptr_size_get (tree vptr) of refs following. */ gfc_expr * -gfc_find_and_cut_at_last_class_ref (gfc_expr *e) +gfc_find_and_cut_at_last_class_ref (gfc_expr *e, bool is_mold) { gfc_expr *base_expr; gfc_ref *ref, *class_ref, *tail = NULL, *array_ref; @@ -394,7 +394,10 @@ gfc_find_and_cut_at_last_class_ref (gfc_expr *e) e->ref = NULL; } - base_expr = gfc_copy_expr (e); + if (is_mold) + base_expr = gfc_expr_to_initialize (e); + else + base_expr = gfc_copy_expr (e); /* Restore the original tail expression. */ if (class_ref) |