From d05ccada1798ac57d8d46abbca18ba122d8b85f3 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Sun, 19 May 2019 12:32:55 +0000 Subject: [PATCH] re PR fortran/90498 (ICE with select type/associate and derived type argument containing class(*)) 2019-05-19 Paul Thomas PR fortran/90498 * trans-stmt.c (trans_associate_var) Do not use the saved descriptor if the expression is a COMPONENT_REF. 2019-05-19 Paul Thomas PR fortran/90498 * gfortran.dg/associate_48.f90 : New test. From-SVN: r271380 --- gcc/fortran/ChangeLog | 6 ++++ gcc/fortran/trans-stmt.c | 3 +- gcc/testsuite/ChangeLog | 7 +++- gcc/testsuite/gfortran.dg/associate_48.f90 | 41 ++++++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/associate_48.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a8e188c6624..dd54e59de67 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-05-19 Paul Thomas + + PR fortran/90498 + * trans-stmt.c (trans_associate_var) Do not use the saved + descriptor if the expression is a COMPONENT_REF. + 2019-05-19 Thomas Koenig PR fortran/90329 diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index b9966ed9318..5fa182bf05a 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -1858,7 +1858,8 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block) { if (e->symtree && DECL_LANG_SPECIFIC (e->symtree->n.sym->backend_decl) - && GFC_DECL_SAVED_DESCRIPTOR (e->symtree->n.sym->backend_decl)) + && GFC_DECL_SAVED_DESCRIPTOR (e->symtree->n.sym->backend_decl) + && TREE_CODE (target_expr) != COMPONENT_REF) /* Use the original class descriptor stored in the saved descriptor to get the target_expr. */ target_expr = diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1352e61c9f4..fe971aa85d3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-05-19 Paul Thomas + + PR fortran/90498 + * gfortran.dg/associate_48.f90 : New test. + 2019-05-19 Thomas Koenig PR fortran/78290 @@ -429,7 +434,7 @@ 2019-05-15 Iain Sandoe - * lib/target-supports.exp + * lib/target-supports.exp (check_effective_target_powerpc_p8vector_ok): No support for Darwin. (check_effective_target_powerpc_p9vector_ok): Likewise. (check_effective_target_powerpc_float128_sw_ok): Likewise. diff --git a/gcc/testsuite/gfortran.dg/associate_48.f90 b/gcc/testsuite/gfortran.dg/associate_48.f90 new file mode 100644 index 00000000000..5ce3a496d14 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_48.f90 @@ -0,0 +1,41 @@ +! { dg=do run } +! +! Test the fix for PR90498. +! +! Contributed by Vladimir Fuka +! + type field_names_a + class(*), pointer :: var(:) =>null() + end type + + type(field_names_a),pointer :: a(:) + allocate (a(2)) + + allocate (a(1)%var(2), source = ["hello"," vlad"]) + allocate (a(2)%var(2), source = ["HELLO"," VLAD"]) + call s(a) + deallocate (a(1)%var) + deallocate (a(2)%var) + deallocate (a) +contains + subroutine s(a) + + type(field_names_a) :: a(:) + + select type (var => a(1)%var) + type is (character(*)) + if (any (var .ne. ["hello"," vlad"])) stop 1 + class default + stop + end select + + associate (var => a(2)%var) + select type (var) + type is (character(*)) + if (any (var .ne. ["HELLO"," VLAD"])) stop 2 + class default + stop + end select + end associate + end +end -- 2.30.2