[gfortran,patch] PR32594: clean up a few substring features

FX Coudert fxcoudert@gmail.com
Mon Aug 13 23:47:00 GMT 2007


Hi all,

Attached simple patch fixes two different bugs pertaining to PR32594,  
because a few cases of substrings weren't handled. These cases are  
when the start or end of the substring is not specified: string(2:)  
or string(:7), which result in the substrings (gfc_ref * ref)- 
 >u.ss.start and gfc_ref * ref)->u.ss.end being NULL, respectively.  
This case was simplified correctly when the base string is a  
constant: this is what the fix in gfc_simplify_expr() does.

The second corner case is the one of string(:). It may not be the  
most used and useful substring, but it exists and the front-end  
signals this case by setting the substring's expr->ref to NULL. There  
are actually a few places in the front-end which didn't deal with  
this at all: one is gfc_simplify_expr(), fixed at the same time as  
above, the others are gfc_is_constant_expr and  
gfc_conv_substring_expr. The first is fixed simply because string(:)  
is constant if and only if string itself is constant. The second is  
fixed by building a copy of the string as substring, without calling  
gfc_conv_substring.

Regtested on x86_64-linux, comes with a testcase, OK to commit?




:ADDPATCH fortran:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr32594.ChangeLog
Type: application/octet-stream
Size: 478 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070813/57a8009d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr32594.diff
Type: application/octet-stream
Size: 3813 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070813/57a8009d/attachment-0001.obj>


More information about the Fortran mailing list