re PR fortran/16861 ([4.0 only] segfault with doubly used module)
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>
Tue, 19 Apr 2005 07:10:05 +0000 (09:10 +0200)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Tue, 19 Apr 2005 07:10:05 +0000 (07:10 +0000)
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
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr16861.f90 [new file with mode: 0644]

index 372d17c5312e5d051cb8f9d70f3a392a6cd57907..998bbf3aeacaed4f6e505c298f0fc2277893871d 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-19  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       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 <pault@gcc.gnu.org>
 
        PR fortran/17472
index 16db94342d10d0d4c50d723da39d6b0eefe6a20f..d75704bc8e2f2128a0c14b0dbaaac44463a3e05b 100644 (file)
@@ -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)
     {
index 57dc0fe0c4c06ff2cc560021e1c7e57c361235ef..bf8cccd520f3229a8955e99b6fba6f20ecd27618 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-18  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR fortran/16861
+       * gfortran.dg/pr16861.f90: New test.
+
 2005-04-18  James A. Morrison  <phython@gcc.gnu.org>
 
        * 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 (file)
index 0000000..4a73eda
--- /dev/null
@@ -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