]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/70524 (ICE when using -frepack-arrays -Warray-temporaries)
authorAndre Vehreschild <vehre@gcc.gnu.org>
Mon, 8 Aug 2016 08:24:22 +0000 (10:24 +0200)
committerAndre Vehreschild <vehre@gcc.gnu.org>
Mon, 8 Aug 2016 08:24:22 +0000 (10:24 +0200)
gcc/testsuite/ChangeLog:

2016-08-08  Andre Vehreschild  <vehre@gcc.gnu.org>

Backport from trunk:
PR fortran/70524
* gfortran.dg/dependency_48.f90: New test.

gcc/fortran/ChangeLog:

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.

From-SVN: r239232

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/dependency_48.f90 [new file with mode: 0644]

index a8a80cc7b15201654181623dd88c0947ff17ca4e..49cb5fb941c3f125b6110793ae79c8ae0427b268 100644 (file)
@@ -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 a40194f3284cea6c6870a58fcd66f27be610f1e6..f9855f6f8e43c9951abad916a84bdd3d15c0720f 100644 (file)
@@ -5928,7 +5928,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.  */
index a68e94dfd61525047c6c05f4b83343a9a98aa13d..ce077a3f55ce13e97bb870ff452e6fd6d8a5a4b9 100644 (file)
@@ -3975,6 +3975,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.  */
@@ -3984,8 +3986,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);
index 28499f0c7c5aa3667834a163e92a9399548fd248..27e767f1c994b2a351caadd5f1d8c554853374d2 100644 (file)
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/dependency_48.f90 b/gcc/testsuite/gfortran.dg/dependency_48.f90
new file mode 100644 (file)
index 0000000..6470019
--- /dev/null
@@ -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