diff options
author | Tobias Burnus <burnus@net-b.de> | 2012-06-16 20:13:38 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2012-06-16 20:13:38 +0200 |
commit | 0f6bfefdef06889fa31e3df1ef4646bc5b3fac67 (patch) | |
tree | c75bea65aa3f216143f0f4e7bacfc3482aa72174 /gcc/fortran/frontend-passes.c | |
parent | 9510c5af63b0b1c357331d8e01a77ceda38f5369 (diff) | |
download | gcc-0f6bfefdef06889fa31e3df1ef4646bc5b3fac67.zip gcc-0f6bfefdef06889fa31e3df1ef4646bc5b3fac67.tar.gz gcc-0f6bfefdef06889fa31e3df1ef4646bc5b3fac67.tar.bz2 |
re PR fortran/53642 (Front-end optimization: Wrong string length for deferred-length strings)
2012-06-16 Tobias Burnus <burnus@net-b.de>
PR fortran/53642
PR fortran/45170
* frontend-passes.c (optimize_assignment): Don't remove RHS's
trim when assigning to a deferred-length string.
* trans-expr.c (gfc_trans_assignment_1): Ensure that the RHS string
length is evaluated before the deferred-length LHS is reallocated.
2012-06-16 Tobias Burnus <burnus@net-b.de>
PR fortran/53642
PR fortran/45170
* gfortran.dg/deferred_type_param_8.f90: New.
From-SVN: r188692
Diffstat (limited to 'gcc/fortran/frontend-passes.c')
-rw-r--r-- | gcc/fortran/frontend-passes.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index bcc1bdc..fc32e56 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -735,15 +735,13 @@ optimize_assignment (gfc_code * c) lhs = c->expr1; rhs = c->expr2; - if (lhs->ts.type == BT_CHARACTER) + if (lhs->ts.type == BT_CHARACTER && !lhs->ts.deferred) { - /* Optimize away a = trim(b), where a is a character variable. */ + /* Optimize a = trim(b) to a = b. */ remove_trim (rhs); - /* Replace a = ' ' by a = '' to optimize away a memcpy, but only - for strings with non-deferred length (otherwise we would - reallocate the length. */ - if (empty_string(rhs) && ! lhs->ts.deferred) + /* Replace a = ' ' by a = '' to optimize away a memcpy. */ + if (empty_string(rhs)) rhs->value.character.length = 0; } @@ -1171,7 +1169,7 @@ optimize_trim (gfc_expr *e) ref->u.ss.start = gfc_get_int_expr (gfc_default_integer_kind, NULL, 1); - /* Build the function call to len_trim(x, gfc_defaul_integer_kind). */ + /* Build the function call to len_trim(x, gfc_default_integer_kind). */ fcn = get_len_trim_call (gfc_copy_expr (e), gfc_default_integer_kind); |