diff options
author | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-11-04 09:07:09 +0000 |
---|---|---|
committer | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-11-04 09:07:09 +0000 |
commit | 8c089b5c15a7b35644750ca393f1e66071ad9aa9 (patch) | |
tree | 9cfc4eb9f5646646c65966c675409c8089598d49 | |
parent | a1920064e26eb99300facfe9c19606534f07f74f (diff) | |
download | gcc-8c089b5c15a7b35644750ca393f1e66071ad9aa9.tar.gz |
2017-11-04 Paul Thomas <pault@gcc.gnu.org>
PR fortran/81735
* trans-decl.c (gfc_trans_deferred_vars): Do a better job of a
case where 'tmp' was used unititialized and remove TODO.
2017-11-04 Paul Thomas <pault@gcc.gnu.org>
PR fortran/81735
* gfortran.dg/pr81735.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254404 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-decl.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr81735.f90 | 25 |
4 files changed, 40 insertions, 5 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f653267b8e6..aa43ff4ebff 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2017-11-04 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/81735 + * trans-decl.c (gfc_trans_deferred_vars): Do a better job of a + case where 'tmp' was used unititialized and remove TODO. + 2017-11-03 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/82796 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index c21611c5d6c..45d5119236a 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -4584,7 +4584,10 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) && sym->ts.u.cl->passed_length) tmp = gfc_null_and_pass_deferred_len (sym, &init, &loc); else - gfc_restore_backend_locus (&loc); + { + gfc_restore_backend_locus (&loc); + tmp = NULL_TREE; + } /* Deallocate when leaving the scope. Nullifying is not needed. */ @@ -4636,10 +4639,6 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) } gfc_add_init_cleanup (block, gfc_finish_block (&init), tmp); - /* TODO find out why this is necessary to stop double calls to - free. Somebody is reusing the expression in 'tmp' because - it is being used unititialized. */ - tmp = NULL_TREE; } } else if (sym->ts.type == BT_CHARACTER && sym->ts.deferred) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 87500b7ecee..10331b39929 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-11-04 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/81735 + * gfortran.dg/pr81735.f90: New test. + 2017-11-03 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/82796 diff --git a/gcc/testsuite/gfortran.dg/pr81735.f90 b/gcc/testsuite/gfortran.dg/pr81735.f90 new file mode 100644 index 00000000000..6aae203aa0f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr81735.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! +! Contributed by Danila <flashmozzg@gmail.com> +! +program fooprog + implicit none + type FooType + integer, allocatable :: x + end type FooType + + type(FooType), pointer :: bar + + bar => foo() + +contains + function foo() result(res) + type(FooType), pointer :: res + + character(:), allocatable :: rt + rt = "" + res => null() + end function foo +end program fooprog +! { dg-final { scan-tree-dump-times "__builtin_free" 1 "original" } } |