summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvehre <vehre@138bc75d-0d04-0410-961f-82ee72b054a4>2016-12-14 12:49:45 +0000
committervehre <vehre@138bc75d-0d04-0410-961f-82ee72b054a4>2016-12-14 12:49:45 +0000
commit0be9bcea21da703c71e1f9625cbf16b30d51da4f (patch)
treeed8425094da3122291186b03d4e3ee9a23706911
parent3fe3b7cac93f9da23baf1d01ae90ff738a72b380 (diff)
downloadgcc-0be9bcea21da703c71e1f9625cbf16b30d51da4f.tar.gz
gcc/testsuite/ChangeLog:
2016-12-14 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/78780 * gfortran.dg/coarray/alloc_comp_5.f90: New test. * gfortran.dg/coarray_42.f90: New test. gcc/fortran/ChangeLog: 2016-12-14 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/78780 * trans-expr.c (gfc_trans_assignment_1): Improve check whether detour caf-runtime routines is needed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243648 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/trans-expr.c17
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/coarray/alloc_comp_5.f9017
-rw-r--r--gcc/testsuite/gfortran.dg/coarray_42.f9020
5 files changed, 62 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 3b6cefcb371..c7acf44c884 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,11 @@
2016-12-14 Andre Vehreschild <vehre@gcc.gnu.org>
+ PR fortran/78780
+ * trans-expr.c (gfc_trans_assignment_1): Improve check whether detour
+ caf-runtime routines is needed.
+
+2016-12-14 Andre Vehreschild <vehre@gcc.gnu.org>
+
PR fortran/78672
* array.c (gfc_find_array_ref): Add flag to return NULL when no ref is
found instead of erroring out.
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 2f45d40bec7..f908c25b9cb 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -9718,7 +9718,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
bool scalar_to_array;
tree string_length;
int n;
- bool maybe_workshare = false;
+ bool maybe_workshare = false, lhs_refs_comp = false, rhs_refs_comp = false;
symbol_attribute lhs_caf_attr, rhs_caf_attr, lhs_attr;
bool is_poly_assign;
@@ -9758,8 +9758,8 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
mode. */
if (flag_coarray == GFC_FCOARRAY_LIB)
{
- lhs_caf_attr = gfc_caf_attr (expr1);
- rhs_caf_attr = gfc_caf_attr (expr2);
+ lhs_caf_attr = gfc_caf_attr (expr1, false, &lhs_refs_comp);
+ rhs_caf_attr = gfc_caf_attr (expr2, false, &rhs_refs_comp);
}
if (lss != gfc_ss_terminator)
@@ -9959,10 +9959,19 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
}
else if (flag_coarray == GFC_FCOARRAY_LIB
&& lhs_caf_attr.codimension && rhs_caf_attr.codimension
- && lhs_caf_attr.alloc_comp && rhs_caf_attr.alloc_comp)
+ && ((lhs_caf_attr.allocatable && lhs_refs_comp)
+ || (rhs_caf_attr.allocatable && rhs_refs_comp)))
{
+ /* Only detour to caf_send[get][_by_ref] () when the lhs or rhs is an
+ allocatable component, because those need to be accessed via the
+ caf-runtime. No need to check for coindexes here, because resolve
+ has rewritten those already. */
gfc_code code;
gfc_actual_arglist a1, a2;
+ /* Clear the structures to prevent accessing garbage. */
+ memset (&code, '\0', sizeof (gfc_code));
+ memset (&a1, '\0', sizeof (gfc_actual_arglist));
+ memset (&a2, '\0', sizeof (gfc_actual_arglist));
a1.expr = expr1;
a1.next = &a2;
a2.expr = expr2;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ba535647648..e353ee051ec 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2016-12-14 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/78780
+ * gfortran.dg/coarray/alloc_comp_5.f90: New test.
+ * gfortran.dg/coarray_42.f90: New test.
+
2016-12-14 Jakub Jelinek <jakub@redhat.com>
PR target/78796
diff --git a/gcc/testsuite/gfortran.dg/coarray/alloc_comp_5.f90 b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_5.f90
new file mode 100644
index 00000000000..bf4fd554303
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_5.f90
@@ -0,0 +1,17 @@
+! { dg-do run }
+
+program Jac
+ type Domain
+ integer :: n=64
+ integer,allocatable :: endsi(:)
+ end type
+ type(Domain),allocatable :: D[:,:,:]
+
+ allocate(D[2,2,*])
+ allocate(D%endsi(2), source = 0)
+ ! No caf-runtime call needed her.
+ D%endsi(2) = D%n
+ if (any(D%endsi /= [ 0, 64])) error stop
+ deallocate(D)
+end program
+
diff --git a/gcc/testsuite/gfortran.dg/coarray_42.f90 b/gcc/testsuite/gfortran.dg/coarray_42.f90
new file mode 100644
index 00000000000..e8db60d496d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_42.f90
@@ -0,0 +1,20 @@
+! { dg-do run }
+! { dg-options "-fdump-tree-original -fcoarray=lib -lcaf_single" }
+
+program Jac
+ type Domain
+ integer :: n=64
+ integer,allocatable :: endsi(:)
+ end type
+ type(Domain),allocatable :: D[:,:,:]
+
+ allocate(D[2,2,*])
+ allocate(D%endsi(2), source = 0)
+ ! Lhs may be reallocate, so caf_send_by_ref needs to be used.
+ D%endsi = D%n
+ if (any(D%endsi /= [ 64, 64])) error stop
+ deallocate(D)
+end program
+
+! { dg-final { scan-tree-dump-times "caf_send_by_ref" 1 "original" } }
+