diff options
author | Harald Anlauf <anlauf@gmx.de> | 2021-01-14 20:25:33 +0100 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2021-01-14 20:25:33 +0100 |
commit | bdd1b1f55529da00b867ef05a53a08fbfc3d1c2e (patch) | |
tree | f17fdbfa2b6eee1ecd66faa80e0292f69fef5c2c /gcc/fortran/resolve.c | |
parent | 3651c1b5c9c0960e50f00ca5b59d144b8a586b5d (diff) | |
download | gcc-bdd1b1f55529da00b867ef05a53a08fbfc3d1c2e.zip gcc-bdd1b1f55529da00b867ef05a53a08fbfc3d1c2e.tar.gz gcc-bdd1b1f55529da00b867ef05a53a08fbfc3d1c2e.tar.bz2 |
PR fortran/93340 - fix missed substring simplifications
Substrings were not reduced early enough for use in initializations,
such as DATA statements. Add an early simplification for substrings
with constant starting and ending points.
gcc/fortran/ChangeLog:
* gfortran.h (gfc_resolve_substring): Add prototype.
* primary.c (match_string_constant): Simplify substrings with
constant starting and ending points.
* resolve.c: Rename resolve_substring to gfc_resolve_substring.
(gfc_resolve_ref): Use renamed function gfc_resolve_substring.
gcc/testsuite/ChangeLog:
* substr_10.f90: New test.
* substr_9.f90: New test.
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r-- | gcc/fortran/resolve.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index ab7ffc2..bb069ef 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -5068,8 +5068,8 @@ resolve_array_ref (gfc_array_ref *ar) } -static bool -resolve_substring (gfc_ref *ref, bool *equal_length) +bool +gfc_resolve_substring (gfc_ref *ref, bool *equal_length) { int k = gfc_validate_kind (BT_INTEGER, gfc_charlen_int_kind, false); @@ -5277,7 +5277,7 @@ gfc_resolve_ref (gfc_expr *expr) case REF_SUBSTRING: equal_length = false; - if (!resolve_substring (*prev, &equal_length)) + if (!gfc_resolve_substring (*prev, &equal_length)) return false; if (expr->expr_type != EXPR_SUBSTRING && equal_length) |