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] PR55343 - Fix ICE with renaming of symbols of intrinsic modules


We freed the renamed symbol for intrinsic modules too early, if they actually exist on the disk as the name is used in trans*.c. (For "file" modules, the data is later freed with the namespace by calling gfc_free_use_stmts.)

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias
2012-12-04  Tobias Burnus  <burnus@net-b.de>

	PR fortran/55343
	* module.c (gfc_use_module): Free rename list only for
	internally generated intrinsic modules.

2012-12-04  Tobias Burnus  <burnus@net-b.de>

	PR fortran/55343
	* gfortran.dg/gomp/use_intrinsic_1.f90: New.

diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 16ea97b..cde5739 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -6157,6 +6157,8 @@ gfc_use_module (gfc_use_list *module)
 			     "intrinsic module at %C") != FAILURE)
        {
 	 use_iso_fortran_env_module ();
+	 free_rename (module->rename);
+	 module->rename = NULL;
 	 gfc_current_locus = old_locus;
 	 module->intrinsic = true;
 	 return;
@@ -6167,6 +6169,8 @@ gfc_use_module (gfc_use_list *module)
 			     "ISO_C_BINDING module at %C") != FAILURE)
 	{
 	  import_iso_c_binding_module();
+	  free_rename (module->rename);
+	  module->rename = NULL;
 	  gfc_current_locus = old_locus;
 	  module->intrinsic = true;
 	  return;
@@ -6359,8 +6363,6 @@ gfc_use_modules (void)
       next = module_list->next;
       rename_list_remove_duplicate (module_list->rename);
       gfc_use_module (module_list);
-      if (module_list->intrinsic)
-	free_rename (module_list->rename);
       free (module_list);
     }
   gfc_rename_list = NULL;
diff --git a/gcc/testsuite/gfortran.dg/gomp/use_intrinsic_1.f90 b/gcc/testsuite/gfortran.dg/gomp/use_intrinsic_1.f90
new file mode 100644
index 0000000..cab3526
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/use_intrinsic_1.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+!
+! PR fortran/55343
+!
+! Contributed by Erik Toussaint
+!
+
+use, intrinsic :: omp_lib, only: omp_get_num_threads
+use, intrinsic :: omp_lib_kinds , foo => omp_lock_kind
+print *, foo
+end

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