Patchwork [Fortran] PR55343 - Fix ICE with renaming of symbols of intrinsic modules

login
register
mail settings
Submitter Tobias Burnus
Date Dec. 4, 2012, 11:22 a.m.
Message ID <50BDDCEC.2040403@net-b.de>
Download mbox | patch
Permalink /patch/203611/
State New
Headers show

Comments

Tobias Burnus - Dec. 4, 2012, 11:22 a.m.
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
Janus Weil - Dec. 8, 2012, 5:14 p.m.
2012/12/4 Tobias Burnus <burnus@net-b.de>:
> 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?

Sorry, I don't get it. Wrong PR number? It sounds related, but the
test case is very different from the one in the PR ...?!?

Cheers,
Janus
Tobias Burnus - Dec. 9, 2012, 3:38 p.m.
Janus Weil wrote:
> Sorry, I don't get it. Wrong PR number? It sounds related, but the 
> test case is very different from the one in the PR ...?!?

Sorry, I copied the PR number from the wrong PR. (I had opened the other 
PR because they are similar.)

The patch is for PR 55197, only.

Tobias

Patch

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