aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Vehreschild <vehre@gcc.gnu.org>2016-04-04 11:32:28 +0200
committerAndre Vehreschild <vehre@gcc.gnu.org>2016-04-04 11:32:28 +0200
commitde517e644a374f7df40bf0b43254684dab717ac0 (patch)
tree0359da9c7ee2fde9145b6988e87491fb19e9ceb8
parent43b9f499103ccebb9ce00e7c62e11da54334e63a (diff)
downloadgcc-de517e644a374f7df40bf0b43254684dab717ac0.zip
gcc-de517e644a374f7df40bf0b43254684dab717ac0.tar.gz
gcc-de517e644a374f7df40bf0b43254684dab717ac0.tar.bz2
re PR fortran/65795 (Segfault (invalid write) for ALLOCATE statement involving COARRAYS)
gcc/fortran/ChangeLog: 2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/65795 * trans-array.c (gfc_array_allocate): When the array is a coarray, do not nullyfing its allocatable components in array_allocate, because the nullify missed the array ref and nullifies the wrong component. Cosmetics. gcc/testsuite/ChangeLog: 2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/65795 * gfortran.dg/coarray_allocate_6.f08: New test. From-SVN: r234710
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/trans-array.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/coarray_allocate_6.f0827
4 files changed, 42 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 5ab7d3f..88ac1cc 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/65795
+ * trans-array.c (gfc_array_allocate): When the array is a coarray,
+ do not nullyfing its allocatable components in array_allocate, because
+ the nullify missed the array ref and nullifies the wrong component.
+ Cosmetics.
+
2016-03-29 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70397
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 649b80f..825dfb8 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -5550,8 +5550,8 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg,
else
gfc_add_expr_to_block (&se->pre, set_descriptor);
- if ((expr->ts.type == BT_DERIVED)
- && expr->ts.u.derived->attr.alloc_comp)
+ if (expr->ts.type == BT_DERIVED && expr->ts.u.derived->attr.alloc_comp
+ && !coarray)
{
tmp = gfc_nullify_alloc_comp (expr->ts.u.derived, se->expr,
ref->u.ar.as->rank);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 43bad0f..47656a9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/65795
+ * gfortran.dg/coarray_allocate_6.f08: New test.
+
2016-04-04 Richard Biener <rguenther@suse.de>
PR rtl-optimization/70484
diff --git a/gcc/testsuite/gfortran.dg/coarray_allocate_6.f08 b/gcc/testsuite/gfortran.dg/coarray_allocate_6.f08
new file mode 100644
index 0000000..2fdd4c1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_allocate_6.f08
@@ -0,0 +1,27 @@
+! { dg-do run }
+! { dg-options "-fcoarray=single -fdump-tree-original" }
+
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+! Test fix for pr65795.
+
+implicit none
+
+type t2
+ integer, allocatable :: x
+end type t2
+
+type t3
+ type(t2), allocatable :: caf[:]
+end type t3
+
+!type(t3), save, target :: c, d
+type(t3), target :: c, d
+integer :: stat
+
+allocate(c%caf[*], stat=stat)
+end
+
+! Besides checking that the executable does not crash anymore, check
+! that the cause has been remove.
+! { dg-final { scan-tree-dump-not "c.caf.x = 0B" "original" } }
+