aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2018-09-30 13:52:55 +0000
committerPaul Thomas <pault@gcc.gnu.org>2018-09-30 13:52:55 +0000
commita086078b8f7ee2580e55afc03026acf63bfb9605 (patch)
tree16e4ee88506a0816352bbb6f207faa23c1c50f4b /gcc/fortran/trans-array.c
parentba08c70a0c73b9fef5b78e2e5706845aa85c4df7 (diff)
downloadgcc-a086078b8f7ee2580e55afc03026acf63bfb9605.zip
gcc-a086078b8f7ee2580e55afc03026acf63bfb9605.tar.gz
gcc-a086078b8f7ee2580e55afc03026acf63bfb9605.tar.bz2
re PR fortran/87359 (pointer being freed was not allocated)
2018-09-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/87359 * trans-array.c (gfc_is_reallocatable_lhs): Correct the problem introduced by r264358, which prevented components of associate names from being reallocated on assignment. 2018-09-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/87359 * gfortran.dg/associate_40.f90 : New test. From-SVN: r264725
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 035257a..1e8f777 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -9574,11 +9574,12 @@ gfc_is_reallocatable_lhs (gfc_expr *expr)
sym = expr->symtree->n.sym;
- if (sym->attr.associate_var)
+ if (sym->attr.associate_var && !expr->ref)
return false;
/* An allocatable class variable with no reference. */
if (sym->ts.type == BT_CLASS
+ && !sym->attr.associate_var
&& CLASS_DATA (sym)->attr.allocatable
&& expr->ref && expr->ref->type == REF_COMPONENT
&& strcmp (expr->ref->u.c.component->name, "_data") == 0
@@ -9587,9 +9588,10 @@ gfc_is_reallocatable_lhs (gfc_expr *expr)
/* An allocatable variable. */
if (sym->attr.allocatable
- && expr->ref
- && expr->ref->type == REF_ARRAY
- && expr->ref->u.ar.type == AR_FULL)
+ && !sym->attr.associate_var
+ && expr->ref
+ && expr->ref->type == REF_ARRAY
+ && expr->ref->u.ar.type == AR_FULL)
return true;
/* All that can be left are allocatable components. */