diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2016-01-27 21:24:01 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2016-01-27 21:24:01 +0000 |
commit | 49847d759f449f0b299fae28932e996037338f88 (patch) | |
tree | d710a896ffd59a5b49bb3d8aeed4e52002ce8bd5 /gcc | |
parent | 9525851d49b18b8b62c47fd2092dbb3937b887f7 (diff) | |
download | gcc-49847d759f449f0b299fae28932e996037338f88.zip gcc-49847d759f449f0b299fae28932e996037338f88.tar.gz gcc-49847d759f449f0b299fae28932e996037338f88.tar.bz2 |
[multiple changes]
2016-01-27 Paul Thomas <pault@gcc.gnu.org>
PR fortran/69385
* trans-expr.c (is_scalar_reallocatable_lhs): Remove the check
for allocatable components, whilst checking if the symbol is a
derived or class entity..
2015-01-27 Paul Thomas <pault@gcc.gnu.org>
PR fortran/69385
* gfortran.dg/alloc_comp_assign_15.f03: New test.
From-SVN: r232904
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/alloc_comp_assign_15.f03 | 32 |
4 files changed, 48 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0a55a09..9fd8ec8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2016-01-27 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/69385 + * trans-expr.c (is_scalar_reallocatable_lhs): Remove the check + for allocatable components, whilst checking if the symbol is a + derived or class entity.. + 2016-01-26 Paul Thomas <pault@gcc.gnu.org> PR fortran/69385 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 5031a37..c5ae4c5 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -8901,10 +8901,11 @@ is_scalar_reallocatable_lhs (gfc_expr *expr) && !expr->ref) return true; - /* All that can be left are allocatable components. */ - if ((expr->symtree->n.sym->ts.type != BT_DERIVED + /* All that can be left are allocatable components. However, we do + not check for allocatable components here because the expression + could be an allocatable component of a pointer component. */ + if (expr->symtree->n.sym->ts.type != BT_DERIVED && expr->symtree->n.sym->ts.type != BT_CLASS) - || !expr->symtree->n.sym->ts.u.derived->attr.alloc_comp) return false; /* Find an allocatable component ref last. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ee9413..e1e3868 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-01-27 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/69385 + * gfortran.dg/alloc_comp_assign_15.f03: New test. + 2016-01-27 Jakub Jelinek <jakub@redhat.com> PR debug/66869 diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_assign_15.f03 b/gcc/testsuite/gfortran.dg/alloc_comp_assign_15.f03 new file mode 100644 index 0000000..94e0400 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/alloc_comp_assign_15.f03 @@ -0,0 +1,32 @@ +! { dg-do run } +! +! Check the test for PR69422, in which the allocatable component 'Source' +! of the pointer component 'P' was not automatically (re)allocated on +! assignment. +! +! Contributed by Anthony Lewis <antony@cosmologist.info> +! +module funcs + implicit none + + Type T + character(LEN=:), allocatable :: source + end type T + + type TPointer + Type(T), pointer :: P + end type TPointer + +end module + +program Test1 + use funcs + Type(TPointer) :: X + + allocate(X%P) + + X%P%Source = 'test string' + if (.not.allocated (X%P%Source)) call abort + if (X%P%Source .ne. 'test string') call abort + +end program Test1 |