re PR fortran/34545 (ICE when compiling Fortran 95 code)
authorPaul Thomas <pault@gcc.gnu.org>
Sun, 6 Jan 2008 22:00:00 +0000 (22:00 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sun, 6 Jan 2008 22:00:00 +0000 (22:00 +0000)
2008-01-06  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/34545
* module.c (load_needed): If the namespace has no proc_name
give it the module symbol.

2008-01-06  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/34545
* gfortran.dg/use_12.f90: New test.

From-SVN: r131364

gcc/fortran/ChangeLog
gcc/fortran/module.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/use_12.f90 [new file with mode: 0644]

index 09155e3f26a98be8135238d0078b133feb0da892..6659ab50f70e322f7ebd34abc6c194d2292296b2 100644 (file)
@@ -1,8 +1,8 @@
-2008-01-06  Tobias Burnus  <burnus@net-b.de>
+2008-01-06  Paul Thomas  <pault@gcc.gnu.org>
 
-       PR fortran/34689
-       * interface.c (compare_actual_formal): Fix intent(out) check for
-       function result variables.
+       PR fortran/34545
+       * module.c (load_needed): If the namespace has no proc_name
+       give it the module symbol.
 
 2008-01-06  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
index f3c54b7d0a6145a6f692ee4685206c0789c531ca..20528cbdc279b6b71fc77b63b0c2297bd468499c 100644 (file)
@@ -3525,6 +3525,12 @@ load_needed (pointer_info *p)
          associate_integer_pointer (q, ns);
        }
 
+      /* Use the module sym as 'proc_name' so that gfc_get_symbol_decl
+        doesn't go pear-shaped if the symbol is used.  */
+      if (!ns->proc_name)
+       gfc_find_symbol (p->u.rsym.module, gfc_current_ns,
+                                1, &ns->proc_name);
+
       sym = gfc_new_symbol (p->u.rsym.true_name, ns);
       sym->module = gfc_get_string (p->u.rsym.module);
       strcpy (sym->binding_label, p->u.rsym.binding_label);
index 5a835561e76c75ace9655647fd28588a2b001ffa..d66912b2ac2aff2f2895c51eef6393cb55fe52d3 100644 (file)
@@ -1,3 +1,14 @@
+2008-01-06  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/34545
+       * gfortran.dg/use_12.f90: New test.
+
+2008-01-06  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/34689
+       * interface.c (compare_actual_formal): Fix intent(out) check for
+       function result variables.
+
 2008-01-06  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/34690
diff --git a/gcc/testsuite/gfortran.dg/use_12.f90 b/gcc/testsuite/gfortran.dg/use_12.f90
new file mode 100644 (file)
index 0000000..82614b5
--- /dev/null
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! Tests the fix of PR34545, in which the 'numclusters' that determines the size
+! of fnres was not properly associated.
+!
+! Reported by Jon D. Richards <jon_d_r@msn.com>
+!
+module m1
+  integer :: numclusters = 2
+end module m1
+
+module m2
+  contains
+    function get_nfirst( ) result(fnres)
+      use m1, only: numclusters
+      real :: fnres(numclusters)   ! change to REAL and it works!!  
+    end function get_nfirst
+end module m2
+
+program kmeans_driver
+   use m1
+   use m2
+   integer :: nfirst(3)
+   nfirst(1:numclusters) = get_nfirst( )
+end program kmeans_driver
+! { dg-final { cleanup-modules "m1 m2" } }