summaryrefslogtreecommitdiff
path: root/gcc/fortran/frontend-passes.c
diff options
context:
space:
mode:
authortkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2012-06-07 14:33:51 +0000
committertkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2012-06-07 14:33:51 +0000
commit08e9fd769bd09efeafc52feb775a252f94244158 (patch)
treeac735e58e700b48825a6f46d36538fddc78a11b0 /gcc/fortran/frontend-passes.c
parent7bfdbc175f2c4b8e24c74bc77e4fc7cb804fab9c (diff)
downloadgcc-08e9fd769bd09efeafc52feb775a252f94244158.tar.gz
2012-06-07 Thomas König <tkoenig@gcc.gnu.org>
PR fortran/52861 * frontend-passes.c (optimize_assignment): Don't set the length of an empty string for deferred-length character variables. 2012-06-07 Thomas König <tkoenig@gcc.gnu.org> PR fortran/52861 * gfortran.dg/string_assign_2.f90: New test case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188305 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/frontend-passes.c')
-rw-r--r--gcc/fortran/frontend-passes.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 4fd24c2947e..bcc1bdc323b 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -740,8 +740,10 @@ optimize_assignment (gfc_code * c)
/* Optimize away a = trim(b), where a is a character variable. */
remove_trim (rhs);
- /* Replace a = ' ' by a = '' to optimize away a memcpy. */
- if (empty_string(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)
rhs->value.character.length = 0;
}