From 30253e235699f233b54f0ee147235bdec5759ac8 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 1 Feb 2019 23:54:05 +0100 Subject: [PATCH] re PR fortran/83246 (internal compiler error or loader problem might be related to a PARAMETER statement being in a BLOCK) PR fortran/83246 PR fortran/89084 * trans-decl.c (generate_local_decl): Add referenced FL_PARAMETERs if sym->ns->construct_entities rather than if sym->ns->parent->code->op == EXEC_BLOCK. * gfortran.dg/pr89084.f90: New test. * gfortran.dg/lto/pr89084_0.f90: New test. * gfortran.dg/pr83246.f90: New test. From-SVN: r268462 --- gcc/fortran/ChangeLog | 8 +++++++ gcc/fortran/trans-decl.c | 5 +---- gcc/testsuite/ChangeLog | 8 +++++++ gcc/testsuite/gfortran.dg/lto/pr89084_0.f90 | 24 +++++++++++++++++++++ gcc/testsuite/gfortran.dg/pr83246.f90 | 9 ++++++++ gcc/testsuite/gfortran.dg/pr89084.f90 | 23 ++++++++++++++++++++ 6 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/lto/pr89084_0.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr83246.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr89084.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7f2a7afbbb9..0a5da36a601 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2019-02-01 Jakub Jelinek + + PR fortran/83246 + PR fortran/89084 + * trans-decl.c (generate_local_decl): Add referenced FL_PARAMETERs + if sym->ns->construct_entities rather than if + sym->ns->parent->code->op == EXEC_BLOCK. + 2019-01-31 Thomas Koenig PR fortran/88669 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 1fe11651816..b8f50f74e1a 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -5735,10 +5735,7 @@ generate_local_decl (gfc_symbol * sym) "imported at %L", sym->name, &sym->declared_at); } - if (sym->ns - && sym->ns->parent - && sym->ns->parent->code - && sym->ns->parent->code->op == EXEC_BLOCK) + if (sym->ns && sym->ns->construct_entities) { if (sym->attr.referenced) gfc_get_symbol_decl (sym); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1df9ba2674d..02a4b857e0e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-02-01 Jakub Jelinek + + PR fortran/83246 + PR fortran/89084 + * gfortran.dg/pr89084.f90: New test. + * gfortran.dg/lto/pr89084_0.f90: New test. + * gfortran.dg/pr83246.f90: New test. + 2019-02-01 Marek Polacek PR c++/88325 - ICE with invalid out-of-line template member definition. diff --git a/gcc/testsuite/gfortran.dg/lto/pr89084_0.f90 b/gcc/testsuite/gfortran.dg/lto/pr89084_0.f90 new file mode 100644 index 00000000000..2c49749da21 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/lto/pr89084_0.f90 @@ -0,0 +1,24 @@ +! PR fortran/89084 +! { dg-lto-do link } +! { dg-lto-options {{ -O0 -flto }} } + +integer function foo () + write (*,*) 'foo' + block + integer, parameter :: idxs(3) = (/ 1, 2, 3 /) + integer :: i + foo = 0 + do i = 1, size(idxs) + foo = foo + idxs(i) + enddo + end block +end function foo +program pr89084 + integer :: i + interface + integer function foo () + end function + end interface + i = foo () + if (i.ne.6) stop 1 +end diff --git a/gcc/testsuite/gfortran.dg/pr83246.f90 b/gcc/testsuite/gfortran.dg/pr83246.f90 new file mode 100644 index 00000000000..32097e3fd38 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr83246.f90 @@ -0,0 +1,9 @@ +! PR fortran/83246 +! { dg-do link } + program dusty_corner + write(*,*)'BLOCK TESTS' + MAKEDATAP: block + integer,parameter :: scratch(*)=[1,2,3] + write(*,*)scratch + endblock MAKEDATAP + end program dusty_corner diff --git a/gcc/testsuite/gfortran.dg/pr89084.f90 b/gcc/testsuite/gfortran.dg/pr89084.f90 new file mode 100644 index 00000000000..3ac6b37999e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr89084.f90 @@ -0,0 +1,23 @@ +! PR fortran/89084 +! { dg-do run } + +integer function foo () + write (*,*) 'foo' + block + integer, parameter :: idxs(3) = (/ 1, 2, 3 /) + integer :: i + foo = 0 + do i = 1, size(idxs) + foo = foo + idxs(i) + enddo + end block +end function foo +program pr89084 + integer :: i + interface + integer function foo () + end function + end interface + i = foo () + if (i.ne.6) stop 1 +end -- 2.30.2