* [Fortran, Patch, pr70524, v1] [5/6/7 Regression] ICE when using -frepack-arrays -Warray-temporaries
@ 2016-07-25 10:55 Andre Vehreschild
2016-08-06 9:07 ` Ping " Andre Vehreschild
0 siblings, 1 reply; 4+ messages in thread
From: Andre Vehreschild @ 2016-07-25 10:55 UTC (permalink / raw)
To: GCC-Patches-ML, GCC-Fortran-ML
[-- Attachment #1: Type: text/plain, Size: 722 bytes --]
Hi all,
the attached patch fixes the ICE when the options in the title are
used. Two issues caused this ICE:
1. the error-printing routines relied on the locus.nextc which was not
set by the gfc_set_backend_locus() and is now set by the patch
(locally, not in gfc_set_backend_locus()).
2. the locus of the function whose result triggered the warning (and
with it the ICE) was set too late.
Both issues are addressed by the patch. Albeit I am not quite sure,
whether my solution to 1. (the first chunk in the patch) is ok this
way.
Bootstraps and regtests ok on x86_64-linux-gnu/F23.
Ok for trunk? And with one week delay for gcc-5- and -6-branch?
Regards,
Andre
--
Andre Vehreschild * Email: vehre ad gmx dot de
[-- Attachment #2: pr70524_1.clog --]
[-- Type: application/octet-stream, Size: 430 bytes --]
gcc/testsuite/ChangeLog:
2016-07-25 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70524
* gfortran.dg/dependency_48.f90: New test.
gcc/fortran/ChangeLog:
2016-07-25 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70524
* trans-array.c (gfc_trans_dummy_array_bias): Ensure that the
location information is correctly set.
* trans-decl.c (gfc_trans_deferred_vars): Set the locus of the
current construct early.
[-- Attachment #3: pr70524_1.patch --]
[-- Type: text/x-patch, Size: 2335 bytes --]
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index e95c8dd..d52cd11 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -6103,7 +6103,12 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc,
return;
}
+ loc.nextc = NULL;
gfc_save_backend_locus (&loc);
+ /* loc.nextc is not set by save_backend_locus but the location routines
+ depend on it. */
+ if (loc.nextc == NULL)
+ loc.nextc = loc.lb->line;
gfc_set_backend_locus (&sym->declared_at);
/* Descriptor type. */
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 05dfcb4..2a34a4c 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -4087,6 +4087,8 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
else if (proc_sym->as)
{
tree result = TREE_VALUE (current_fake_result_decl);
+ gfc_save_backend_locus (&loc);
+ gfc_set_backend_locus (&proc_sym->declared_at);
gfc_trans_dummy_array_bias (proc_sym, result, block);
/* An automatic character length, pointer array result. */
@@ -4096,8 +4098,6 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
tmp = NULL;
if (proc_sym->ts.deferred)
{
- gfc_save_backend_locus (&loc);
- gfc_set_backend_locus (&proc_sym->declared_at);
gfc_start_block (&init);
tmp = gfc_null_and_pass_deferred_len (proc_sym, &init, &loc);
gfc_add_init_cleanup (block, gfc_finish_block (&init), tmp);
diff --git a/gcc/testsuite/gfortran.dg/dependency_48.f90 b/gcc/testsuite/gfortran.dg/dependency_48.f90
new file mode 100644
index 0000000..6470019
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dependency_48.f90
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! { dg-options "-frepack-arrays -Warray-temporaries -O" }
+
+! Same as dependency_35 but with repack-arrays
+
+module foo
+ implicit none
+contains
+ pure function bar(i,j) ! { dg-warning "Creating array temporary at \\(1\\)" }
+ integer, intent(in) :: i,j
+ integer, dimension(2,2) :: bar
+ bar = 33
+ end function bar
+end module foo
+
+program main
+ use foo
+ implicit none
+ integer a(2,2), b(2,2),c(2,2), d(2,2), e(2)
+
+ read (*,*) b, c, d
+ a = matmul(b,c) + d
+ a = b + bar(3,4)
+ a = bar(3,4)*5 + b
+ e = sum(b,1) + 3
+end program main
^ permalink raw reply [flat|nested] 4+ messages in thread
* Ping [Fortran, Patch, pr70524, v1] [5/6/7 Regression] ICE when using -frepack-arrays -Warray-temporaries
2016-07-25 10:55 [Fortran, Patch, pr70524, v1] [5/6/7 Regression] ICE when using -frepack-arrays -Warray-temporaries Andre Vehreschild
@ 2016-08-06 9:07 ` Andre Vehreschild
2016-08-08 6:37 ` Thomas Koenig
0 siblings, 1 reply; 4+ messages in thread
From: Andre Vehreschild @ 2016-08-06 9:07 UTC (permalink / raw)
To: GCC-Patches-ML, GCC-Fortran-ML
[-- Attachment #1: Type: text/plain, Size: 851 bytes --]
Ping.
On Mon, 25 Jul 2016 12:55:14 +0200
Andre Vehreschild <vehre@gmx.de> wrote:
> Hi all,
>
> the attached patch fixes the ICE when the options in the title are
> used. Two issues caused this ICE:
>
> 1. the error-printing routines relied on the locus.nextc which was not
> set by the gfc_set_backend_locus() and is now set by the patch
> (locally, not in gfc_set_backend_locus()).
>
> 2. the locus of the function whose result triggered the warning (and
> with it the ICE) was set too late.
>
> Both issues are addressed by the patch. Albeit I am not quite sure,
> whether my solution to 1. (the first chunk in the patch) is ok this
> way.
>
> Bootstraps and regtests ok on x86_64-linux-gnu/F23.
>
> Ok for trunk? And with one week delay for gcc-5- and -6-branch?
>
> Regards,
> Andre
--
Andre Vehreschild * Email: vehre ad gmx dot de
[-- Attachment #2: pr70524_1.clog --]
[-- Type: text/plain, Size: 430 bytes --]
gcc/testsuite/ChangeLog:
2016-07-25 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70524
* gfortran.dg/dependency_48.f90: New test.
gcc/fortran/ChangeLog:
2016-07-25 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70524
* trans-array.c (gfc_trans_dummy_array_bias): Ensure that the
location information is correctly set.
* trans-decl.c (gfc_trans_deferred_vars): Set the locus of the
current construct early.
[-- Attachment #3: pr70524_1.patch --]
[-- Type: text/x-patch, Size: 2335 bytes --]
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index e95c8dd..d52cd11 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -6103,7 +6103,12 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc,
return;
}
+ loc.nextc = NULL;
gfc_save_backend_locus (&loc);
+ /* loc.nextc is not set by save_backend_locus but the location routines
+ depend on it. */
+ if (loc.nextc == NULL)
+ loc.nextc = loc.lb->line;
gfc_set_backend_locus (&sym->declared_at);
/* Descriptor type. */
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 05dfcb4..2a34a4c 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -4087,6 +4087,8 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
else if (proc_sym->as)
{
tree result = TREE_VALUE (current_fake_result_decl);
+ gfc_save_backend_locus (&loc);
+ gfc_set_backend_locus (&proc_sym->declared_at);
gfc_trans_dummy_array_bias (proc_sym, result, block);
/* An automatic character length, pointer array result. */
@@ -4096,8 +4098,6 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
tmp = NULL;
if (proc_sym->ts.deferred)
{
- gfc_save_backend_locus (&loc);
- gfc_set_backend_locus (&proc_sym->declared_at);
gfc_start_block (&init);
tmp = gfc_null_and_pass_deferred_len (proc_sym, &init, &loc);
gfc_add_init_cleanup (block, gfc_finish_block (&init), tmp);
diff --git a/gcc/testsuite/gfortran.dg/dependency_48.f90 b/gcc/testsuite/gfortran.dg/dependency_48.f90
new file mode 100644
index 0000000..6470019
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dependency_48.f90
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! { dg-options "-frepack-arrays -Warray-temporaries -O" }
+
+! Same as dependency_35 but with repack-arrays
+
+module foo
+ implicit none
+contains
+ pure function bar(i,j) ! { dg-warning "Creating array temporary at \\(1\\)" }
+ integer, intent(in) :: i,j
+ integer, dimension(2,2) :: bar
+ bar = 33
+ end function bar
+end module foo
+
+program main
+ use foo
+ implicit none
+ integer a(2,2), b(2,2),c(2,2), d(2,2), e(2)
+
+ read (*,*) b, c, d
+ a = matmul(b,c) + d
+ a = b + bar(3,4)
+ a = bar(3,4)*5 + b
+ e = sum(b,1) + 3
+end program main
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ping [Fortran, Patch, pr70524, v1] [5/6/7 Regression] ICE when using -frepack-arrays -Warray-temporaries
2016-08-06 9:07 ` Ping " Andre Vehreschild
@ 2016-08-08 6:37 ` Thomas Koenig
2016-08-08 8:25 ` Andre Vehreschild
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Koenig @ 2016-08-08 6:37 UTC (permalink / raw)
To: Andre Vehreschild, GCC-Patches-ML, GCC-Fortran-ML
Hi Andre,
the patch is OK.
> Ping.
Regards
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ping [Fortran, Patch, pr70524, v1] [5/6/7 Regression] ICE when using -frepack-arrays -Warray-temporaries
2016-08-08 6:37 ` Thomas Koenig
@ 2016-08-08 8:25 ` Andre Vehreschild
0 siblings, 0 replies; 4+ messages in thread
From: Andre Vehreschild @ 2016-08-08 8:25 UTC (permalink / raw)
To: Thomas Koenig; +Cc: GCC-Patches-ML, GCC-Fortran-ML
[-- Attachment #1: Type: text/plain, Size: 366 bytes --]
Hi Thomas,
thanks for the review. Committed as
r239230 in trunk,
r239231 in gcc-6-branch,
r239232 in gcc-5-branch.
Thanks again,
Andre
On Mon, 8 Aug 2016 08:37:16 +0200
Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hi Andre,
>
> the patch is OK.
>
>
> > Ping.
>
> Regards
>
> Thomas
>
--
Andre Vehreschild * Email: vehre ad gmx dot de
[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 3193 bytes --]
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 239229)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,3 +1,11 @@
+2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/70524
+ * trans-array.c (gfc_trans_dummy_array_bias): Ensure that the
+ location information is correctly set.
+ * trans-decl.c (gfc_trans_deferred_vars): Set the locus of the
+ current construct early.
+
2016-08-03 Fritz Reese <fritzoreese@gmail.com>
* lang.opt: New option -fdec-intrinsic-ints.
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (Revision 239229)
+++ gcc/fortran/trans-array.c (Arbeitskopie)
@@ -6103,7 +6103,12 @@
return;
}
+ loc.nextc = NULL;
gfc_save_backend_locus (&loc);
+ /* loc.nextc is not set by save_backend_locus but the location routines
+ depend on it. */
+ if (loc.nextc == NULL)
+ loc.nextc = loc.lb->line;
gfc_set_backend_locus (&sym->declared_at);
/* Descriptor type. */
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (Revision 239229)
+++ gcc/fortran/trans-decl.c (Arbeitskopie)
@@ -4087,6 +4087,8 @@
else if (proc_sym->as)
{
tree result = TREE_VALUE (current_fake_result_decl);
+ gfc_save_backend_locus (&loc);
+ gfc_set_backend_locus (&proc_sym->declared_at);
gfc_trans_dummy_array_bias (proc_sym, result, block);
/* An automatic character length, pointer array result. */
@@ -4096,8 +4098,6 @@
tmp = NULL;
if (proc_sym->ts.deferred)
{
- gfc_save_backend_locus (&loc);
- gfc_set_backend_locus (&proc_sym->declared_at);
gfc_start_block (&init);
tmp = gfc_null_and_pass_deferred_len (proc_sym, &init, &loc);
gfc_add_init_cleanup (block, gfc_finish_block (&init), tmp);
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 239229)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/70524
+ * gfortran.dg/dependency_48.f90: New test.
+
2016-08-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/70040
Index: gcc/testsuite/gfortran.dg/dependency_48.f90
===================================================================
--- gcc/testsuite/gfortran.dg/dependency_48.f90 (nicht existent)
+++ gcc/testsuite/gfortran.dg/dependency_48.f90 (Arbeitskopie)
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! { dg-options "-frepack-arrays -Warray-temporaries -O" }
+
+! Same as dependency_35 but with repack-arrays
+
+module foo
+ implicit none
+contains
+ pure function bar(i,j) ! { dg-warning "Creating array temporary at \\(1\\)" }
+ integer, intent(in) :: i,j
+ integer, dimension(2,2) :: bar
+ bar = 33
+ end function bar
+end module foo
+
+program main
+ use foo
+ implicit none
+ integer a(2,2), b(2,2),c(2,2), d(2,2), e(2)
+
+ read (*,*) b, c, d
+ a = matmul(b,c) + d
+ a = b + bar(3,4)
+ a = bar(3,4)*5 + b
+ e = sum(b,1) + 3
+end program main
[-- Attachment #3: submit_gcc6.diff --]
[-- Type: text/x-patch, Size: 3211 bytes --]
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 239229)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,3 +1,12 @@
+2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ Backport from trunk:
+ PR fortran/70524
+ * trans-array.c (gfc_trans_dummy_array_bias): Ensure that the
+ location information is correctly set.
+ * trans-decl.c (gfc_trans_deferred_vars): Set the locus of the
+ current construct early.
+
2016-08-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/71795
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (Revision 239229)
+++ gcc/fortran/trans-array.c (Arbeitskopie)
@@ -6093,7 +6093,12 @@
return;
}
+ loc.nextc = NULL;
gfc_save_backend_locus (&loc);
+ /* loc.nextc is not set by save_backend_locus but the location routines
+ depend on it. */
+ if (loc.nextc == NULL)
+ loc.nextc = loc.lb->line;
gfc_set_backend_locus (&sym->declared_at);
/* Descriptor type. */
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (Revision 239229)
+++ gcc/fortran/trans-decl.c (Arbeitskopie)
@@ -4050,6 +4050,8 @@
else if (proc_sym->as)
{
tree result = TREE_VALUE (current_fake_result_decl);
+ gfc_save_backend_locus (&loc);
+ gfc_set_backend_locus (&proc_sym->declared_at);
gfc_trans_dummy_array_bias (proc_sym, result, block);
/* An automatic character length, pointer array result. */
@@ -4059,8 +4061,6 @@
tmp = NULL;
if (proc_sym->ts.deferred)
{
- gfc_save_backend_locus (&loc);
- gfc_set_backend_locus (&proc_sym->declared_at);
gfc_start_block (&init);
tmp = gfc_null_and_pass_deferred_len (proc_sym, &init, &loc);
gfc_add_init_cleanup (block, gfc_finish_block (&init), tmp);
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 239229)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,9 @@
+2016-07-25 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ Backport from trunk:
+ PR fortran/70524
+ * gfortran.dg/dependency_48.f90: New test.
+
2016-08-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/71795
Index: gcc/testsuite/gfortran.dg/dependency_48.f90
===================================================================
--- gcc/testsuite/gfortran.dg/dependency_48.f90 (nicht existent)
+++ gcc/testsuite/gfortran.dg/dependency_48.f90 (Arbeitskopie)
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! { dg-options "-frepack-arrays -Warray-temporaries -O" }
+
+! Same as dependency_35 but with repack-arrays
+
+module foo
+ implicit none
+contains
+ pure function bar(i,j) ! { dg-warning "Creating array temporary at \\(1\\)" }
+ integer, intent(in) :: i,j
+ integer, dimension(2,2) :: bar
+ bar = 33
+ end function bar
+end module foo
+
+program main
+ use foo
+ implicit none
+ integer a(2,2), b(2,2),c(2,2), d(2,2), e(2)
+
+ read (*,*) b, c, d
+ a = matmul(b,c) + d
+ a = b + bar(3,4)
+ a = bar(3,4)*5 + b
+ e = sum(b,1) + 3
+end program main
[-- Attachment #4: submit_gcc-5.diff --]
[-- Type: text/x-patch, Size: 3235 bytes --]
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 239230)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,3 +1,12 @@
+2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ Backport from trunk:
+ PR fortran/70524
+ * trans-array.c (gfc_trans_dummy_array_bias): Ensure that the
+ location information is correctly set.
+ * trans-decl.c (gfc_trans_deferred_vars): Set the locus of the
+ current construct early.
+
2016-07-29 Steven G. Kargl <kargl@gcc.gnu.org>
Thomas Koenig <tkoenig@gcc.gnu.org>
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (Revision 239230)
+++ gcc/fortran/trans-array.c (Arbeitskopie)
@@ -5928,7 +5928,12 @@
return;
}
+ loc.nextc = NULL;
gfc_save_backend_locus (&loc);
+ /* loc.nextc is not set by save_backend_locus but the location routines
+ depend on it. */
+ if (loc.nextc == NULL)
+ loc.nextc = loc.lb->line;
gfc_set_backend_locus (&sym->declared_at);
/* Descriptor type. */
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (Revision 239230)
+++ gcc/fortran/trans-decl.c (Arbeitskopie)
@@ -3975,6 +3975,8 @@
else if (proc_sym->as)
{
tree result = TREE_VALUE (current_fake_result_decl);
+ gfc_save_backend_locus (&loc);
+ gfc_set_backend_locus (&proc_sym->declared_at);
gfc_trans_dummy_array_bias (proc_sym, result, block);
/* An automatic character length, pointer array result. */
@@ -3984,8 +3986,6 @@
tmp = NULL;
if (proc_sym->ts.deferred)
{
- gfc_save_backend_locus (&loc);
- gfc_set_backend_locus (&proc_sym->declared_at);
gfc_start_block (&init);
tmp = gfc_null_and_pass_deferred_len (proc_sym, &init, &loc);
gfc_add_init_cleanup (block, gfc_finish_block (&init), tmp);
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 239230)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,9 @@
+2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ Backport from trunk:
+ PR fortran/70524
+ * gfortran.dg/dependency_48.f90: New test.
+
2016-08-08 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/70040
Index: gcc/testsuite/gfortran.dg/dependency_48.f90
===================================================================
--- gcc/testsuite/gfortran.dg/dependency_48.f90 (nicht existent)
+++ gcc/testsuite/gfortran.dg/dependency_48.f90 (Arbeitskopie)
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! { dg-options "-frepack-arrays -Warray-temporaries -O" }
+
+! Same as dependency_35 but with repack-arrays
+
+module foo
+ implicit none
+contains
+ pure function bar(i,j) ! { dg-warning "Creating array temporary at \\(1\\)" }
+ integer, intent(in) :: i,j
+ integer, dimension(2,2) :: bar
+ bar = 33
+ end function bar
+end module foo
+
+program main
+ use foo
+ implicit none
+ integer a(2,2), b(2,2),c(2,2), d(2,2), e(2)
+
+ read (*,*) b, c, d
+ a = matmul(b,c) + d
+ a = b + bar(3,4)
+ a = bar(3,4)*5 + b
+ e = sum(b,1) + 3
+end program main
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-08 8:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-25 10:55 [Fortran, Patch, pr70524, v1] [5/6/7 Regression] ICE when using -frepack-arrays -Warray-temporaries Andre Vehreschild
2016-08-06 9:07 ` Ping " Andre Vehreschild
2016-08-08 6:37 ` Thomas Koenig
2016-08-08 8:25 ` 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).