This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]