* [Fortran, patch, pr71936, v1] [6/7 Regression] ICE in wide_int_to_tree, at tree.c:1487
@ 2016-08-07 13:32 Andre Vehreschild
2016-08-08 9:33 ` Paul Richard Thomas
0 siblings, 1 reply; 5+ messages in thread
From: Andre Vehreschild @ 2016-08-07 13:32 UTC (permalink / raw)
To: GCC-Patches-ML, GCC-Fortran-ML
[-- Attachment #1: Type: text/plain, Size: 393 bytes --]
Hi all,
attached patch fixes the ICE by ensuring that when the SOURCE=/MOLD=
expression is an array-valued function call with no ref, the ref of
object to allocate is taken. The array properties nevertheless are
taken from the function's result.
Bootstraps and regtests ok on x86_64-linux-gnu/F23. Ok for trunk and
gcc-6?
Regards,
Andre
--
Andre Vehreschild * Email: vehre ad gmx dot de
[-- Attachment #2: pr71936_1.clog --]
[-- Type: text/plain, Size: 360 bytes --]
gcc/fortran/ChangeLog:
2016-08-07 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/71936
* trans-array.c (gfc_array_allocate): When SOURCE= is a function
stick with the ref of the object to allocate.
gcc/testsuite/ChangeLog:
2016-08-07 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/71936
* gfortran.dg/allocate_with_source_21.f03: New test.
[-- Attachment #3: pr71936_1.patch --]
[-- Type: text/x-patch, Size: 1939 bytes --]
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 7572755..6d5a0ef 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -5431,12 +5431,19 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg,
if (ref->u.ar.type == AR_FULL && expr3 != NULL)
{
+ gfc_ref *old_ref = ref;
/* F08:C633: Array shape from expr3. */
ref = expr3->ref;
/* Find the last reference in the chain. */
if (!retrieve_last_ref (&ref, &prev_ref))
- return false;
+ {
+ if (expr3->expr_type == EXPR_FUNCTION
+ && gfc_expr_attr (expr3).dimension)
+ ref = old_ref;
+ else
+ return false;
+ }
alloc_w_e3_arr_spec = true;
}
diff --git a/gcc/testsuite/gfortran.dg/allocate_with_source_21.f03 b/gcc/testsuite/gfortran.dg/allocate_with_source_21.f03
new file mode 100644
index 0000000..fbf3159
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/allocate_with_source_21.f03
@@ -0,0 +1,52 @@
+! { dg-do compile }
+
+! Check fix for pr71936.
+! Contributed by Gerhard Steinmetz
+
+program p
+ type t
+ end type
+
+ call test2()
+ call test4()
+ call test1()
+ call test3()
+contains
+ function f_p()
+ class(t), pointer :: f_p(:)
+ nullify(f_p)
+ end
+
+ function f_a()
+ class(t), allocatable :: f_a(:)
+ end
+
+ subroutine test1()
+ class(t), allocatable :: x(:)
+ allocate (x, mold=f_a())
+ deallocate (x)
+ allocate (x, source=f_a())
+ end subroutine
+
+ subroutine test2()
+ class(t), pointer :: x(:)
+ allocate (x, mold=f_p())
+ deallocate (x)
+ allocate (x, source=f_p())
+ end
+
+ subroutine test3()
+ class(t), pointer :: x(:)
+ allocate (x, mold=f_a())
+ deallocate (x)
+ allocate (x, source=f_a())
+ end
+
+ subroutine test4()
+ class(t), allocatable :: x(:)
+ allocate (x, mold=f_p())
+ deallocate (x)
+ allocate (x, source=f_p())
+ end subroutine
+end
+
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Fortran, patch, pr71936, v1] [6/7 Regression] ICE in wide_int_to_tree, at tree.c:1487
2016-08-07 13:32 [Fortran, patch, pr71936, v1] [6/7 Regression] ICE in wide_int_to_tree, at tree.c:1487 Andre Vehreschild
@ 2016-08-08 9:33 ` Paul Richard Thomas
2016-08-08 9:58 ` Andre Vehreschild
0 siblings, 1 reply; 5+ messages in thread
From: Paul Richard Thomas @ 2016-08-08 9:33 UTC (permalink / raw)
To: Andre Vehreschild; +Cc: GCC-Patches-ML, GCC-Fortran-ML
Hi Andre,
That looks fine to me. OK for 6-branch and trunk.
Thanks for the patch.
Paul
On 7 August 2016 at 15:32, Andre Vehreschild <vehre@gmx.de> wrote:
> Hi all,
>
> attached patch fixes the ICE by ensuring that when the SOURCE=/MOLD=
> expression is an array-valued function call with no ref, the ref of
> object to allocate is taken. The array properties nevertheless are
> taken from the function's result.
>
> Bootstraps and regtests ok on x86_64-linux-gnu/F23. Ok for trunk and
> gcc-6?
>
> Regards,
> Andre
> --
> Andre Vehreschild * Email: vehre ad gmx dot de
--
The difference between genius and stupidity is; genius has its limits.
Albert Einstein
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Fortran, patch, pr71936, v1] [6/7 Regression] ICE in wide_int_to_tree, at tree.c:1487
2016-08-08 9:33 ` Paul Richard Thomas
@ 2016-08-08 9:58 ` Andre Vehreschild
2016-08-09 9:09 ` Richard Biener
0 siblings, 1 reply; 5+ messages in thread
From: Andre Vehreschild @ 2016-08-08 9:58 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: GCC-Patches-ML, GCC-Fortran-ML
[-- Attachment #1: Type: text/plain, Size: 905 bytes --]
Hi Paul,
thanks for the review. Committed to trunk as r239237.
I will commit to gcc-6 in one week.
Regards,
Andre
On Mon, 8 Aug 2016 11:33:06 +0200
Paul Richard Thomas <paul.richard.thomas@gmail.com> wrote:
> Hi Andre,
>
> That looks fine to me. OK for 6-branch and trunk.
>
> Thanks for the patch.
>
> Paul
>
> On 7 August 2016 at 15:32, Andre Vehreschild <vehre@gmx.de> wrote:
> > Hi all,
> >
> > attached patch fixes the ICE by ensuring that when the SOURCE=/MOLD=
> > expression is an array-valued function call with no ref, the ref of
> > object to allocate is taken. The array properties nevertheless are
> > taken from the function's result.
> >
> > Bootstraps and regtests ok on x86_64-linux-gnu/F23. Ok for trunk and
> > gcc-6?
> >
> > Regards,
> > Andre
> > --
> > Andre Vehreschild * Email: vehre ad gmx dot de
>
>
>
--
Andre Vehreschild * Email: vehre ad gmx dot de
[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 2974 bytes --]
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 239236)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,5 +1,11 @@
2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
+ PR fortran/71936
+ * trans-array.c (gfc_array_allocate): When SOURCE= is a function
+ stick with the ref of the object to allocate.
+
+2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
+
PR fortran/72698
* trans-stmt.c (gfc_trans_allocate): Prevent generating code for
copy of zero sized string and with it an ICE.
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (Revision 239235)
+++ gcc/fortran/trans-array.c (Arbeitskopie)
@@ -5431,12 +5431,19 @@
if (ref->u.ar.type == AR_FULL && expr3 != NULL)
{
+ gfc_ref *old_ref = ref;
/* F08:C633: Array shape from expr3. */
ref = expr3->ref;
/* Find the last reference in the chain. */
if (!retrieve_last_ref (&ref, &prev_ref))
- return false;
+ {
+ if (expr3->expr_type == EXPR_FUNCTION
+ && gfc_expr_attr (expr3).dimension)
+ ref = old_ref;
+ else
+ return false;
+ }
alloc_w_e3_arr_spec = true;
}
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 239236)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,5 +1,10 @@
2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
+ PR fortran/71936
+ * gfortran.dg/allocate_with_source_21.f03: New test.
+
+2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
+
PR fortran/72698
* gfortran.dg/allocate_with_source_20.f03: New test.
Index: gcc/testsuite/gfortran.dg/allocate_with_source_21.f03
===================================================================
--- gcc/testsuite/gfortran.dg/allocate_with_source_21.f03 (nicht existent)
+++ gcc/testsuite/gfortran.dg/allocate_with_source_21.f03 (Arbeitskopie)
@@ -0,0 +1,52 @@
+! { dg-do compile }
+
+! Check fix for pr71936.
+! Contributed by Gerhard Steinmetz
+
+program p
+ type t
+ end type
+
+ call test2()
+ call test4()
+ call test1()
+ call test3()
+contains
+ function f_p()
+ class(t), pointer :: f_p(:)
+ nullify(f_p)
+ end
+
+ function f_a()
+ class(t), allocatable :: f_a(:)
+ end
+
+ subroutine test1()
+ class(t), allocatable :: x(:)
+ allocate (x, mold=f_a())
+ deallocate (x)
+ allocate (x, source=f_a())
+ end subroutine
+
+ subroutine test2()
+ class(t), pointer :: x(:)
+ allocate (x, mold=f_p())
+ deallocate (x)
+ allocate (x, source=f_p())
+ end
+
+ subroutine test3()
+ class(t), pointer :: x(:)
+ allocate (x, mold=f_a())
+ deallocate (x)
+ allocate (x, source=f_a())
+ end
+
+ subroutine test4()
+ class(t), allocatable :: x(:)
+ allocate (x, mold=f_p())
+ deallocate (x)
+ allocate (x, source=f_p())
+ end subroutine
+end
+
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Fortran, patch, pr71936, v1] [6/7 Regression] ICE in wide_int_to_tree, at tree.c:1487
2016-08-08 9:58 ` Andre Vehreschild
@ 2016-08-09 9:09 ` Richard Biener
2016-08-11 8:13 ` Andre Vehreschild
0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2016-08-09 9:09 UTC (permalink / raw)
To: Andre Vehreschild; +Cc: Paul Richard Thomas, GCC-Patches-ML, GCC-Fortran-ML
On Mon, Aug 8, 2016 at 11:58 AM, Andre Vehreschild <vehre@gmx.de> wrote:
> Hi Paul,
>
> thanks for the review. Committed to trunk as r239237.
>
> I will commit to gcc-6 in one week.
If you want to catch the 6.2 release then please make sure to have it on the
branch this Friday.
Richard.
> Regards,
> Andre
>
> On Mon, 8 Aug 2016 11:33:06 +0200
> Paul Richard Thomas <paul.richard.thomas@gmail.com> wrote:
>
>> Hi Andre,
>>
>> That looks fine to me. OK for 6-branch and trunk.
>>
>> Thanks for the patch.
>>
>> Paul
>>
>> On 7 August 2016 at 15:32, Andre Vehreschild <vehre@gmx.de> wrote:
>> > Hi all,
>> >
>> > attached patch fixes the ICE by ensuring that when the SOURCE=/MOLD=
>> > expression is an array-valued function call with no ref, the ref of
>> > object to allocate is taken. The array properties nevertheless are
>> > taken from the function's result.
>> >
>> > Bootstraps and regtests ok on x86_64-linux-gnu/F23. Ok for trunk and
>> > gcc-6?
>> >
>> > Regards,
>> > Andre
>> > --
>> > Andre Vehreschild * Email: vehre ad gmx dot de
>>
>>
>>
>
>
> --
> Andre Vehreschild * Email: vehre ad gmx dot de
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Fortran, patch, pr71936, v1] [6/7 Regression] ICE in wide_int_to_tree, at tree.c:1487
2016-08-09 9:09 ` Richard Biener
@ 2016-08-11 8:13 ` Andre Vehreschild
0 siblings, 0 replies; 5+ messages in thread
From: Andre Vehreschild @ 2016-08-11 8:13 UTC (permalink / raw)
To: Richard Biener; +Cc: Paul Richard Thomas, GCC-Patches-ML, GCC-Fortran-ML
[-- Attachment #1: Type: text/plain, Size: 1480 bytes --]
Hi all,
to catch the gcc-6-release I have committed the patch as r239354.
Regards,
Andre
On Tue, 9 Aug 2016 11:09:39 +0200
Richard Biener <richard.guenther@gmail.com> wrote:
> On Mon, Aug 8, 2016 at 11:58 AM, Andre Vehreschild <vehre@gmx.de>
> wrote:
> > Hi Paul,
> >
> > thanks for the review. Committed to trunk as r239237.
> >
> > I will commit to gcc-6 in one week.
>
> If you want to catch the 6.2 release then please make sure to have it
> on the branch this Friday.
>
> Richard.
>
> > Regards,
> > Andre
> >
> > On Mon, 8 Aug 2016 11:33:06 +0200
> > Paul Richard Thomas <paul.richard.thomas@gmail.com> wrote:
> >
> >> Hi Andre,
> >>
> >> That looks fine to me. OK for 6-branch and trunk.
> >>
> >> Thanks for the patch.
> >>
> >> Paul
> >>
> >> On 7 August 2016 at 15:32, Andre Vehreschild <vehre@gmx.de>
> >> wrote:
> >> > Hi all,
> >> >
> >> > attached patch fixes the ICE by ensuring that when the
> >> > SOURCE=/MOLD= expression is an array-valued function call with
> >> > no ref, the ref of object to allocate is taken. The array
> >> > properties nevertheless are taken from the function's result.
> >> >
> >> > Bootstraps and regtests ok on x86_64-linux-gnu/F23. Ok for trunk
> >> > and gcc-6?
> >> >
> >> > Regards,
> >> > Andre
> >> > --
> >> > Andre Vehreschild * Email: vehre ad gmx dot de
> >>
> >>
> >>
> >
> >
> > --
> > Andre Vehreschild * Email: vehre ad gmx dot de
--
Andre Vehreschild * Email: vehre ad gmx dot de
[-- Attachment #2: submit_gcc6.diff --]
[-- Type: text/x-patch, Size: 3017 bytes --]
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 239353)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,5 +1,12 @@
2016-08-11 Andre Vehreschild <vehre@gcc.gnu.org>
+ Backport from trunk:
+ PR fortran/71936
+ * trans-array.c (gfc_array_allocate): When SOURCE= is a function
+ stick with the ref of the object to allocate.
+
+2016-08-11 Andre Vehreschild <vehre@gcc.gnu.org>
+
Backport from trunk
PR fortran/72698
* trans-stmt.c (gfc_trans_allocate): Prevent generating code for
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (Revision 239353)
+++ gcc/fortran/trans-array.c (Arbeitskopie)
@@ -5421,12 +5421,19 @@
if (ref->u.ar.type == AR_FULL && expr3 != NULL)
{
+ gfc_ref *old_ref = ref;
/* F08:C633: Array shape from expr3. */
ref = expr3->ref;
/* Find the last reference in the chain. */
if (!retrieve_last_ref (&ref, &prev_ref))
- return false;
+ {
+ if (expr3->expr_type == EXPR_FUNCTION
+ && gfc_expr_attr (expr3).dimension)
+ ref = old_ref;
+ else
+ return false;
+ }
alloc_w_e3_arr_spec = true;
}
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 239353)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,6 +1,12 @@
2016-08-11 Andre Vehreschild <vehre@gcc.gnu.org>
Backport from trunk:
+ PR fortran/71936
+ * gfortran.dg/allocate_with_source_21.f03: New test.
+
+2016-08-11 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ Backport from trunk:
PR fortran/72698
* gfortran.dg/allocate_with_source_20.f03: New test.
Index: gcc/testsuite/gfortran.dg/allocate_with_source_21.f03
===================================================================
--- gcc/testsuite/gfortran.dg/allocate_with_source_21.f03 (nicht existent)
+++ gcc/testsuite/gfortran.dg/allocate_with_source_21.f03 (Arbeitskopie)
@@ -0,0 +1,52 @@
+! { dg-do compile }
+
+! Check fix for pr71936.
+! Contributed by Gerhard Steinmetz
+
+program p
+ type t
+ end type
+
+ call test2()
+ call test4()
+ call test1()
+ call test3()
+contains
+ function f_p()
+ class(t), pointer :: f_p(:)
+ nullify(f_p)
+ end
+
+ function f_a()
+ class(t), allocatable :: f_a(:)
+ end
+
+ subroutine test1()
+ class(t), allocatable :: x(:)
+ allocate (x, mold=f_a())
+ deallocate (x)
+ allocate (x, source=f_a())
+ end subroutine
+
+ subroutine test2()
+ class(t), pointer :: x(:)
+ allocate (x, mold=f_p())
+ deallocate (x)
+ allocate (x, source=f_p())
+ end
+
+ subroutine test3()
+ class(t), pointer :: x(:)
+ allocate (x, mold=f_a())
+ deallocate (x)
+ allocate (x, source=f_a())
+ end
+
+ subroutine test4()
+ class(t), allocatable :: x(:)
+ allocate (x, mold=f_p())
+ deallocate (x)
+ allocate (x, source=f_p())
+ end subroutine
+end
+
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-08-11 8:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-07 13:32 [Fortran, patch, pr71936, v1] [6/7 Regression] ICE in wide_int_to_tree, at tree.c:1487 Andre Vehreschild
2016-08-08 9:33 ` Paul Richard Thomas
2016-08-08 9:58 ` Andre Vehreschild
2016-08-09 9:09 ` Richard Biener
2016-08-11 8:13 ` Andre Vehreschild
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).