diff options
author | Andre Vehreschild <vehre@gcc.gnu.org> | 2016-07-14 19:07:47 +0200 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2016-07-14 19:07:47 +0200 |
commit | 1f8dd420ebf769bd0b8068af416735f082464575 (patch) | |
tree | 7f737d9f104e3471b6e68a90dba3176927887b54 /gcc | |
parent | aefae0f13c8622a095ae966de321566d529bbd70 (diff) | |
download | gcc-1f8dd420ebf769bd0b8068af416735f082464575.zip gcc-1f8dd420ebf769bd0b8068af416735f082464575.tar.gz gcc-1f8dd420ebf769bd0b8068af416735f082464575.tar.bz2 |
re PR fortran/70842 (internal compiler error with character members within a polymorphic pointer)
gcc/testsuite/ChangeLog:
2016-07-14 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70842
* gfortran.dg/select_type_35.f03: New test.
gcc/fortran/ChangeLog:
2016-07-14 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70842
* simplify.c (gfc_simplify_len): Only for unlimited polymorphic
types replace the expression's _data ref with a _len ref.
From-SVN: r238347
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/simplify.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/select_type_35.f03 | 41 |
4 files changed, 57 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8b71025..0abf7d0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-07-14 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/70842 + * simplify.c (gfc_simplify_len): Only for unlimited polymorphic + types replace the expression's _data ref with a _len ref. + 2016-07-09 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/71783 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 95a8d10..8096a92 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -3816,8 +3816,12 @@ gfc_simplify_len (gfc_expr *e, gfc_expr *kind) } else if (e->expr_type == EXPR_VARIABLE && e->ts.type == BT_CHARACTER && e->symtree->n.sym + && e->symtree->n.sym->ts.type != BT_DERIVED && e->symtree->n.sym->assoc && e->symtree->n.sym->assoc->target - && e->symtree->n.sym->assoc->target->ts.type == BT_DERIVED) + && e->symtree->n.sym->assoc->target->ts.type == BT_DERIVED + && e->symtree->n.sym->assoc->target->symtree->n.sym + && UNLIMITED_POLY (e->symtree->n.sym->assoc->target->symtree->n.sym)) + /* The expression in assoc->target points to a ref to the _data component of the unlimited polymorphic entity. To get the _len component the last _data ref needs to be stripped and a ref to the _len component added. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9eeec45..ef81056 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-14 Andre Vehreschild <vehre@gcc.gnu.org> + + PR fortran/70842 + * gfortran.dg/select_type_35.f03: New test. + 2016-07-14 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR target/65951 diff --git a/gcc/testsuite/gfortran.dg/select_type_35.f03 b/gcc/testsuite/gfortran.dg/select_type_35.f03 new file mode 100644 index 0000000..92d2f27 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_type_35.f03 @@ -0,0 +1,41 @@ +! { dg-do run } +! +! Contributed by Nathanael Huebbe +! Check fix for PR/70842 + +program foo + + TYPE, ABSTRACT :: t_Intermediate + END TYPE t_Intermediate + + type, extends(t_Intermediate) :: t_Foo + character(:), allocatable :: string + end type t_Foo + + class(t_Foo), allocatable :: obj + + allocate(obj) + obj%string = "blabarfoo" + + call bar(obj) + + deallocate(obj) +contains + subroutine bar(me) + class(t_Intermediate), target :: me + + class(*), pointer :: alias + + select type(me) + type is(t_Foo) + if (len(me%string) /= 9) call abort() + end select + + alias => me + select type(alias) + type is(t_Foo) + if (len(alias%string) /= 9) call abort() + end select + end subroutine bar +end program foo + |