This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] PR34545 - ICE when compiling Fortran 95 code


:ADDPATCH fortran:

The attached is explained by the comment in module.c and the
discussion in Bugzilla.  Sorry about the lack of context in the diff -
I just upgraded to FC8 and had to do it from scratch and have not set
svn yet.

Bootstrapped and regtested on FC8/x86_ia64 - OK for trunk?

Paul

Attachment: submit.msg
Description: Binary data

Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c	(revision 131246)
+++ gcc/fortran/module.c	(working copy)
@@ -3525,6 +3525,12 @@
 	  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: gcc/testsuite/gfortran.dg/use_12.f90
===================================================================
--- gcc/testsuite/gfortran.dg/use_12.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/use_12.f90	(revision 0)
@@ -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" } }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]