diff mbox

Ping [Fortran, Patch, pr70524, v1] [5/6/7 Regression] ICE when using -frepack-arrays -Warray-temporaries

Message ID 20160808102444.59cd2018@vepi2
State New
Headers show

Commit Message

Andre Vehreschild Aug. 8, 2016, 8:24 a.m. UTC
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
>
diff mbox

Patch

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