From 8e9218f2b39c5730760a23595f449498f3f4faf6 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Mon, 8 Aug 2016 10:11:29 +0200 Subject: [PATCH] re PR fortran/70524 (ICE when using -frepack-arrays -Warray-temporaries) gcc/testsuite/ChangeLog: 2016-08-08 Andre Vehreschild PR fortran/70524 * gfortran.dg/dependency_48.f90: New test. gcc/fortran/ChangeLog: 2016-08-08 Andre Vehreschild 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: r239230 --- gcc/fortran/ChangeLog | 8 +++++++ gcc/fortran/trans-array.c | 5 ++++ gcc/fortran/trans-decl.c | 4 ++-- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gfortran.dg/dependency_48.f90 | 26 +++++++++++++++++++++ 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/dependency_48.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 04726bb5dc1..bf5ec12c49c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2016-08-08 Andre Vehreschild + + 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 * lang.opt: New option -fdec-intrinsic-ints. diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 7572755a7a6..0a66f83562c 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 05dfcb4be70..2a34a4c2346 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/ChangeLog b/gcc/testsuite/ChangeLog index 57a6c4ba34a..5e5ab27a7fe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-08-08 Andre Vehreschild + + PR fortran/70524 + * gfortran.dg/dependency_48.f90: New test. + 2016-08-07 Thomas Koenig 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 index 00000000000..64700193f70 --- /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 -- 2.30.2