From 009e94d4e654ec6b009ef69d27818bdcf2915246 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Tue, 19 Apr 2005 09:10:05 +0200 Subject: [PATCH] re PR fortran/16861 ([4.0 only] segfault with doubly used module) PR fortran/16861 * resolve.c (resolve_variable): If e->symtree is not set, this ought to be a FAILURE, and not a segfault. * gfortran.dg/pr16861.f90: New test. From-SVN: r98391 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/resolve.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr16861.f90 | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr16861.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 372d17c..998bbf3 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2005-04-19 Francois-Xavier Coudert + + PR fortran/16861 + * resolve.c (resolve_variable): If e->symtree is not set, this + ought to be a FAILURE, and not a segfault. + 2005-04-17 Paul Thomas PR fortran/17472 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 16db943..d75704b 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -2111,6 +2111,9 @@ resolve_variable (gfc_expr * e) if (e->ref && resolve_ref (e) == FAILURE) return FAILURE; + if (e->symtree == NULL) + return FAILURE; + sym = e->symtree->n.sym; if (sym->attr.flavor == FL_PROCEDURE && !sym->attr.function) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 57dc0fe..bf8cccd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-04-18 Francois-Xavier Coudert + + PR fortran/16861 + * gfortran.dg/pr16861.f90: New test. + 2005-04-18 James A. Morrison * gcc.dg/pr21085.c: New test. diff --git a/gcc/testsuite/gfortran.dg/pr16861.f90 b/gcc/testsuite/gfortran.dg/pr16861.f90 new file mode 100644 index 0000000..4a73eda --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr16861.f90 @@ -0,0 +1,32 @@ +! PR fortran/16861 +! { dg-do run } +module foo + integer :: i +end module foo + +module bar +contains + subroutine baz(j) + use foo + integer, dimension(i) :: j + integer :: n + + do n = 1, i + if (j(n) /= n**2) call abort + end do + end subroutine baz +end module bar + +subroutine quus() + use foo + use bar + + i = 2 + call baz ((/1,4/)) + i = 7 + call baz ((/1,4,9,16,25,36,49/)) +end subroutine quus + +program test + call quus +end program test -- 2.7.4