aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-17 06:11:31 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-17 06:11:31 +0000
commite1f64d59740ec48fd76ed3aa0b854c6769794fb6 (patch)
treeae3040b1ada6d87193ab78aad13d35d852b47410
parent0f6af24db77c1d8a4157b038f218f9d9a3cf3b78 (diff)
2011-06-17 Tobias Burnus
PR fortran/49324 * trans-expr.c (gfc_trans_assignment_1): Tell gfc_trans_scalar_assign to also deep-copy RHS nonvariables with allocatable components. * trans-array.c (gfc_conv_expr_descriptor): Ditto. 2011-06-17 Tobias Burnus PR fortran/49324 * gfortran.dg/alloc_comp_assign_11.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@175137 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog10
-rw-r--r--gcc/fortran/trans-array.c3
-rw-r--r--gcc/fortran/trans-expr.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/alloc_comp_assign_11.f9041
5 files changed, 59 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index c4273de3c62..a2eedb6a1a1 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2011-06-17 Tobias Burnus
+
+ PR fortran/49324
+ * trans-expr.c (gfc_trans_assignment_1): Tell
+ gfc_trans_scalar_assign to also deep-copy RHS nonvariables
+ with allocatable components.
+ * trans-array.c (gfc_conv_expr_descriptor): Ditto.
+
2011-06-06 Asher Langton <langton2@llnl.gov>
PR fortran/49268
@@ -11,7 +19,7 @@
procedure statement.
* parse.c ( decode_statement): Deal with whitespace around :: in
gfc_match_modproc.
-
+
2011-05-31 Thomas Koenig <tkoenig@gcc.gnu.org>
Backport from trunk
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index b64e10d6a10..5c3ecaf2874 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -5669,7 +5669,8 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
lse.string_length = rse.string_length;
tmp = gfc_trans_scalar_assign (&lse, &rse, expr->ts, true,
- expr->expr_type == EXPR_VARIABLE, true);
+ expr->expr_type == EXPR_VARIABLE
+ || expr->expr_type == EXPR_ARRAY, true);
gfc_add_expr_to_block (&block, tmp);
/* Finish the copying loops. */
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index ade7e548522..0487f75a051 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -6147,8 +6147,8 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts,
l_is_temp || init_flag,
- expr_is_variable (expr2) || scalar_to_array,
- dealloc);
+ expr_is_variable (expr2) || scalar_to_array
+ || expr2->expr_type == EXPR_ARRAY, dealloc);
gfc_add_expr_to_block (&body, tmp);
if (lss == gfc_ss_terminator)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5d6c403fb16..b47cccaf3e1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-06-17 Tobias Burnus
+
+ PR fortran/49324
+ * gfortran.dg/alloc_comp_assign_11.f90: New.
+
2011-06-16 Jason Merrill <jason@redhat.com>
PR c++/49229
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_assign_11.f90 b/gcc/testsuite/gfortran.dg/alloc_comp_assign_11.f90
new file mode 100644
index 00000000000..2d2b85b841f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/alloc_comp_assign_11.f90
@@ -0,0 +1,41 @@
+! { dg-do run }
+!
+! PR fortran/49324
+!
+! Check that with array constructors a deep copy is done
+!
+implicit none
+type t
+ integer, allocatable :: A(:)
+end type t
+
+type(t) :: x, y
+type(t), allocatable :: z(:), z2(:)
+
+allocate (x%A(2))
+allocate (y%A(1))
+x%A(:) = 11
+y%A(:) = 22
+
+allocate (z(2))
+
+z = [ x, y ]
+!print *, z(1)%a, z(2)%a, x%A, y%A
+if (any (z(1)%a /= 11) .or. z(2)%a(1) /= 22 .or. any (x%A /= 11) &
+ .or. y%A(1) /= 22) &
+ call abort()
+
+x%A(:) = 444
+y%A(:) = 555
+
+!print *, z(1)%a, z(2)%a, x%A, y%A
+if (any (z(1)%a /= 11) .or. z(2)%a(1) /= 22 .or. any (x%A /= 444) &
+ .or. y%A(1) /= 555) &
+ call abort()
+
+z(:) = [ x, y ]
+!print *, z(1)%a, z(2)%a, x%A, y%A
+if (any (z(1)%a /= 444) .or. z(2)%a(1) /= 555 .or. any (x%A /= 444) &
+ .or. y%A(1) /= 555) &
+ call abort()
+end