Re: [PATCH 20/23] test: dynamic string evaluations.

Keven Boell
2014-06-17T13:52:36Z

> On Wed, 04 Jun 2014 07:54:23 +0200, Keven Boell wrote:
>> --- /dev/null
>> +++ b/gdb/testsuite/gdb.fortran/vla-strings.f90
>> @@ -0,0 +1,38 @@
>> +! Copyright 2014 Free Software Foundation, Inc.
>> +!
>> +! This program is free software; you can redistribute it and/or modify
>> +! it under the terms of the GNU General Public License as published by
>> +! the Free Software Foundation; either version 2 of the License, or
>> +! (at your option) any later version.
>> +!
>> +! This program is distributed in the hope that it will be useful,
>> +! but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> +! GNU General Public License for more details.
>> +!
>> +! You should have received a copy of the GNU General Public License
>> +! along with this program; if not, write to the Free Software
>> +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
>> +
>> +program vla_strings
>> + character(len=:), target, allocatable :: var_char
>> + character(len=:), pointer :: var_char_p
>> + logical :: l
>> +
>> + allocate(character(len=10) :: var_char)
>> + l = allocated(var_char) ! var_char-allocated-1
>> + var_char = 'foo'
>> + deallocate(var_char) ! var_char-filled-1
>> + l = allocated(var_char) ! var_char-deallocated
>> + allocate(character(len=42) :: var_char)
>> + l = allocated(var_char)
>> + var_char = 'foobar'
>> + var_char = '' ! var_char-filled-2
>> + allocate(character(len=21) :: var_char) ! var_char-empty
>
> On Fedora Rawhide x86_64 (gcc-4.9.0-8.fc21.x86_64) I get:
> $ ./gdb.fortran/vla-strings
> At line 31 of file ./gdb.fortran/vla-strings.f90
> Fortran runtime error: Attempting to allocate already allocated variable 'var_char'
>
> This also causes:
> Running ./gdb.fortran/vla-strings.exp ...
> FAIL: gdb.fortran/vla-strings.exp: continue to breakpoint: var_char-allocated-3 (the program exited)
> FAIL: gdb.fortran/vla-strings.exp: print var_char after allocated third time
> FAIL: gdb.fortran/vla-strings.exp: whatis var_char after allocated third time
> FAIL: gdb.fortran/vla-strings.exp: ptype var_char after allocated third time
> FAIL: gdb.fortran/vla-strings.exp: continue to breakpoint: var_char_p-associated (the program is no longer running)
> FAIL: gdb.fortran/vla-strings.exp: print var_char_p after associated
> FAIL: gdb.fortran/vla-strings.exp: print *var_char_ after associated
> FAIL: gdb.fortran/vla-strings.exp: whatis var_char_p after associated
> FAIL: gdb.fortran/vla-strings.exp: ptype var_char_p after associated

Thanks for trying out the tests on your system. The test source was
incorrect. I tried to allocate a string, which wasn't deallocated before.
GFORTRAN 4.8.2, which I have on my system, doesn't complain about this mistake,
whereas GFORTRAN 4.9.0 does.
I fixed it and it resolves all of the FAIL's reported above.

>
>
>> + l = allocated(var_char) ! var_char-allocated-3
>> + var_char = 'johndoe'
>> + var_char_p => var_char
>> + l = associated(var_char_p) ! var_char_p-associated
>> + var_char_p => null()
>> + l = associated(var_char_p) ! var_char_p-not-associated
>> +end program vla_strings
>> --
>> 1.7.9.5
>
>
> Thanks,
> Jan
>