This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran,patch] PR32594: clean up a few substring features
- From: FX Coudert <fxcoudert at gmail dot com>
- To: GNU Fortran <fortran at gcc dot gnu dot org>, gcc-patches list <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 14 Aug 2007 00:47:33 +0100
- Subject: [gfortran,patch] PR32594: clean up a few substring features
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:
Attachment:
pr32594.ChangeLog
Description: Binary data
Attachment:
pr32594.diff
Description: Binary data