This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Fortran, Patch, PR70842, v1] [4.9/5/6/7 Regression] internal compiler error with character members within a polymorphic pointer
- From: Andre Vehreschild <vehre at gmx dot de>
- To: Jerry DeLisle <jvdelisle at charter dot net>
- Cc: fortran at gcc dot gnu dot org
- Date: Fri, 22 Jul 2016 17:03:47 +0200
- Subject: Re: [Fortran, Patch, PR70842, v1] [4.9/5/6/7 Regression] internal compiler error with character members within a polymorphic pointer
- Authentication-results: sourceware.org; auth=none
- References: <20160714165607.54c9a364@vepi2> <4b7fb296-ec45-f61a-a957-0428362a28c5@charter.net> <20160714190852.7766bc85@vepi2>
Hi all,
as announced backported to
gcc-6-branch as commit r238640,
gcc-5-branch as commit r238644, and
gcc-4_9-branch as commit r238646.
Best regards,
Andre
On Thu, 14 Jul 2016 19:08:52 +0200
Andre Vehreschild <vehre@gmx.de> wrote:
> Hi Jerry,
>
> thanks for the fast review. Committed to trunk as r238347. Will wait
> one week before applying to the other branches.
>
> Regards,
> Andre
>
> On Thu, 14 Jul 2016 09:12:27 -0700
> Jerry DeLisle <jvdelisle@charter.net> wrote:
>
> > On 07/14/2016 07:56 AM, Andre Vehreschild wrote:
> > > Hi all,
> > >
> > > attached patch fixes the ICE and the wrong char array length
> > > mentioned in comment #3 of the PR. The issue was that getting the
> > > _len component is valid online for unlimited polymorphic pointers.
> > > But here this was tried for polymorphic entity, which had to fail.
> > >
> > > Bootstrapped and regtests ok on trunk, gcc-6-branch, gcc-5-branch,
> > > gcc-4_9-branch. Ok for trunk and one week later for the other
> > > branches?
> > >
> > > Regards,
> > > Andre
> > >
> >
> > Yes, OK and thanks for patch. (Maybe add a blank line just before
> > the existing comment shown in the patch.)
> >
> > Regards,
> >
> > Jerry
>
>
--
Andre Vehreschild * Email: vehre ad gmx dot de
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 238640)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,5 +1,12 @@
2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
+ Backported from trunk:
+ PR fortran/71807
+ * trans-expr.c (gfc_trans_subcomponent_assign): Special casing
+ when allocatable component is set to null() in initializer.
+
+2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
+
Backport from trunk:
PR fortran/70842
* simplify.c (gfc_simplify_len): Only for unlimited polymorphic
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (Revision 238639)
+++ gcc/fortran/trans-expr.c (Arbeitskopie)
@@ -7200,6 +7200,12 @@
tmp = gfc_trans_alloc_subarray_assign (tmp, cm, expr);
gfc_add_expr_to_block (&block, tmp);
}
+ else if (init && cm->attr.allocatable && expr->expr_type == EXPR_NULL)
+ {
+ /* NULL initialization for allocatable components. */
+ gfc_add_modify (&block, dest, fold_convert (TREE_TYPE (dest),
+ null_pointer_node));
+ }
else if (init && (cm->attr.allocatable
|| (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.allocatable
&& expr->ts.type != BT_CLASS)))
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 238640)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,5 +1,11 @@
2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
+ Backported from trunk:
+ PR fortran/71807
+ * gfortran.dg/null_9.f90: New test.
+
+2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
+
Backport from trunk:
PR fortran/70842
* gfortran.dg/select_type_35.f03: New test.
Index: gcc/testsuite/gfortran.dg/null_9.f90
===================================================================
--- gcc/testsuite/gfortran.dg/null_9.f90 (nicht existent)
+++ gcc/testsuite/gfortran.dg/null_9.f90 (Arbeitskopie)
@@ -0,0 +1,30 @@
+! { dg-do run }
+
+MODULE fold_convert_loc_ice
+ IMPLICIT NONE
+ PRIVATE
+
+ TYPE, PUBLIC :: ta
+ PRIVATE
+ INTEGER :: a_comp
+ END TYPE ta
+
+ TYPE, PUBLIC :: tb
+ TYPE(ta), ALLOCATABLE :: b_comp
+ END TYPE tb
+
+ PUBLIC :: proc
+CONTAINS
+ SUBROUTINE proc
+ TYPE(tb) :: b
+
+ b = tb(null())
+ if (allocated( b%b_comp )) call abort()
+ END SUBROUTINE proc
+END MODULE fold_convert_loc_ice
+
+ USE fold_convert_loc_ice
+
+ call proc()
+END
+
Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c (Revision 238638)
+++ gcc/fortran/simplify.c (Arbeitskopie)
@@ -3692,8 +3692,12 @@
}
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. */
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 238638)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,9 @@
+2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ Backport from trunk:
+ PR fortran/70842
+ * gfortran.dg/select_type_35.f03: New test.
+
2016-07-20 Jakub Jelinek <jakub@redhat.com>
PR c++/71909
Index: gcc/testsuite/gfortran.dg/select_type_35.f03
===================================================================
--- gcc/testsuite/gfortran.dg/select_type_35.f03 (nicht existent)
+++ gcc/testsuite/gfortran.dg/select_type_35.f03 (Arbeitskopie)
@@ -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
+
Index: gcc/testsuite/gfortran.dg/select_type_35.f03
===================================================================
--- gcc/testsuite/gfortran.dg/select_type_35.f03 (nicht existent)
+++ gcc/testsuite/gfortran.dg/select_type_35.f03 (Revision 238644)
@@ -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
+
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 238643)
+++ gcc/testsuite/ChangeLog (Revision 238644)
@@ -1,3 +1,9 @@
+2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ Backport from trunk:
+ PR fortran/70842
+ * gfortran.dg/select_type_35.f03: New test.
+
2016-07-20 Jakub Jelinek <jakub@redhat.com>
PR c++/71909
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 238643)
+++ gcc/fortran/ChangeLog (Revision 238644)
@@ -1,3 +1,10 @@
+2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ Backport from trunk:
+ 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-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Backport from trunk:
Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c (Revision 238643)
+++ gcc/fortran/simplify.c (Revision 238644)
@@ -3713,8 +3713,12 @@
}
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. */