From: Paul Thomas Date: Wed, 22 Nov 2017 11:37:16 +0000 (+0000) Subject: re PR fortran/79072 (ICE with class(*) pointer function result and character value) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a7d3cd407ccea644f1405cf331edf3bb30e57e65;p=gcc.git re PR fortran/79072 (ICE with class(*) pointer function result and character value) 2017-11-22 Paul Thomas PR fortran/79072 * trans-stmt.c (trans_associate_var): Weaken the over strong condition for using the fake result decl. 2017-11-22 Paul Thomas PR fortran/79072 * gfortran.dg/class_result_6.f90: New test for comment 10 of the PR. From-SVN: r255053 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4ba7327be33..7fc965baf81 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2017-11-22 Paul Thomas + + PR fortran/79072 + * trans-stmt.c (trans_associate_var): Weaken the over strong + condition for using the fake result decl. + 2017-11-20 Paul Thomas PR fortran/79072 diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 6cf79816099..db913bfe515 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -1828,8 +1828,7 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block) tmp = e->symtree->n.sym->ts.u.cl->backend_decl; } else if (e->symtree->n.sym->attr.function - && e->symtree->n.sym == e->symtree->n.sym->result - && e->symtree->n.sym == e->symtree->n.sym->ns->proc_name) + && e->symtree->n.sym == e->symtree->n.sym->result) { tmp = gfc_get_fake_result_decl (e->symtree->n.sym, 0); tmp = gfc_class_len_get (tmp); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7bfd96b8e02..39dd1446bac 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-11-22 Paul Thomas + + PR fortran/79072 + * gfortran.dg/class_result_6.f90: New test for comment 10 of + the PR. + 2017-11-22 Jakub Jelinek PR debug/83084 diff --git a/gcc/testsuite/gfortran.dg/class_result_6.f90 b/gcc/testsuite/gfortran.dg/class_result_6.f90 new file mode 100644 index 00000000000..44e17a22025 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_result_6.f90 @@ -0,0 +1,24 @@ +! { dg-do run } +! +! Test the fix for PR79072 comment #12. A description of the problem +! is to be found in class_result_5.f90. +! +! Contributed by Neil Carlson +! + character(3), target :: a = 'foo' + class(*), pointer :: b + b => ptr() + select type (b) + type is (character(*)) + if (a .ne. "bar") call abort + end select +contains + function ptr() + class(*), pointer :: ptr + ptr => a + select type (ptr) + type is (character(*)) + ptr = "bar" + end select + end function +end