Commit ce1ff48e by Paul Thomas

re PR fortran/69423 (Invalid optimization with deferred-length character)

2016-02-20  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/69423
	* trans-decl.c (create_function_arglist): Deferred character
	length functions, with and without declared results, address
	the passed reference type as '.result' and the local string
	length as '..result'.
	(gfc_null_and_pass_deferred_len): Helper function to null and
	return deferred string lengths, as needed.
	(gfc_trans_deferred_vars): Call it, thereby reducing repeated
	code, add call for deferred arrays and reroute pointer function
	results. Avoid using 'tmp' for anything other that a temporary
	tree by introducing 'type_of_array' for the arrayspec type.

2016-02-20  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/69423
	* gfortran.dg/deferred_character_15.f90 : New test.

From-SVN: r233589
parent bbf27208
2016-02-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/69423
* trans-decl.c (create_function_arglist): Deferred character
length functions, with and without declared results, address
the passed reference type as '.result' and the local string
length as '..result'.
(gfc_null_and_pass_deferred_len): Helper function to null and
return deferred string lengths, as needed.
(gfc_trans_deferred_vars): Call it, thereby reducing repeated
code, add call for deferred arrays and reroute pointer function
results. Avoid using 'tmp' for anything other that a temporary
tree by introducing 'type_of_array' for the arrayspec type.
2015-02-16 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/69742
......
2016-02-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/69423
* gfortran.dg/deferred_character_15.f90 : New test.
2016-02-20 Dominique d'Humieres <dominiq@lps.ens.fr>
PR fortran/57365
......
! { dg-do run }
!
! Test the fix for PR69423.
!
! Contributed by Antony Lewis <antony@cosmologist.info>
!
program tester
character(LEN=:), allocatable :: S
S= test(2)
if (len(S) .ne. 4) call abort
if (S .ne. "test") call abort
if (allocated (S)) deallocate (S)
S= test2(2)
if (len(S) .ne. 4) call abort
if (S .ne. "test") call abort
if (allocated (S)) deallocate (S)
contains
function test(alen)
character(LEN=:), allocatable :: test
integer alen, i
do i = alen, 1, -1
test = 'test'
exit
end do
! This line would print nothing when compiled with -O1 and higher.
! print *, len(test),test
if (len(test) .ne. 4) call abort
if (test .ne. "test") call abort
end function test
function test2(alen) result (test)
character(LEN=:), allocatable :: test
integer alen, i
do i = alen, 1, -1
test = 'test'
exit
end do
! This worked before the fix.
! print *, len(test),test
if (len(test) .ne. 4) call abort
if (test .ne. "test") call abort
end function test2
end program tester
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment