+2011-05-11 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ * frontend-passes.c (optimize_assignment): Follow chains
+ of concatenation operators to the end for removing trailing
+ TRIMS for assignments.
+
2011-06-10 Daniel Carrera <dcarrera@gmail.com>
* trans-decl.c (gfc_build_builtin_function_decls):
if (lhs->ts.type == BT_CHARACTER)
{
+ /* Check for a // b // trim(c). Looping is probably not
+ necessary because the parser usually generates
+ (// (// a b ) trim(c) ) , but better safe than sorry. */
+
+ while (rhs->expr_type == EXPR_OP
+ && rhs->value.op.op == INTRINSIC_CONCAT)
+ rhs = rhs->value.op.op2;
+
if (rhs->expr_type == EXPR_FUNCTION &&
rhs->value.function.isym &&
rhs->value.function.isym->id == GFC_ISYM_TRIM)
+2011-05-11 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ * gfortran.dg/trim_optimize_7.f90: New test.
+
2011-06-10 Wei Guozhi <carrot@google.com>
PR target/45335
--- /dev/null
+! { dg-do run }
+! { dg-options "-O -fdump-tree-original" }
+! Check that trailing trims are also removed from assignment of
+! expressions involving concatenations of strings .
+program main
+ character(2) :: a,b,c
+ character(8) :: d
+ a = 'a '
+ b = 'b '
+ c = 'c '
+ d = a // b // a // trim(c) ! This should be optimized away.
+ if (d /= 'a b a c ') call abort
+ d = a // trim(b) // c // a ! This shouldn't.
+ if (d /= 'a bc a ') call abort
+ d = a // b // a // trim(trim(c)) ! This should also be optimized away.
+ if (d /= 'a b a c ') call abort
+end
+! { dg-final { scan-tree-dump-times "string_len_trim" 1 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }