OSDN Git Service

2008-01-07 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Jan 2008 16:44:43 +0000 (16:44 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Jan 2008 16:44:43 +0000 (16:44 +0000)
PR fortran/34672
* module.c (write_generic): Rewrite completely.
(write_module): Change call to write_generic.

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

PR fortran/34672
* gfortran.dg/use_only_2.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131377 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 8b56942..19f822f 100644 (file)
@@ -1,3 +1,9 @@
+2008-01-07  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/34672
+       * module.c (write_generic): Rewrite completely.
+       (write_module): Change call to write_generic.
+
 2008-01-06  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/34659
index 20528cb..20cec83 100644 (file)
@@ -4176,13 +4176,22 @@ write_operator (gfc_user_op *uop)
 }
 
 
-/* Write generic interfaces associated with a symbol.  */
+/* Write generic interfaces from the namespace sym_root.  */
 
 static void
-write_generic (gfc_symbol *sym)
+write_generic (gfc_symtree *st)
 {
-  const char *p;
-  int nuse, j;
+  gfc_symbol *sym;
+
+  if (st == NULL)
+    return;
+
+  write_generic (st->left);
+  write_generic (st->right);
+
+  sym = st->n.sym;
+  if (!sym || check_unique_name (st->name))
+    return;
 
   if (sym->generic == NULL
       || !gfc_check_access (sym->attr.access, sym->ns->default_access))
@@ -4191,21 +4200,7 @@ write_generic (gfc_symbol *sym)
   if (sym->module == NULL)
     sym->module = gfc_get_string (module_name);
 
-  /* See how many use names there are.  If none, use the symbol name.  */
-  nuse = number_use_names (sym->name, false);
-  if (nuse == 0)
-    {
-      mio_symbol_interface (&sym->name, &sym->module, &sym->generic);
-      return;
-    }
-
-  for (j = 1; j <= nuse; j++)
-    {
-      /* Get the jth local name for this symbol.  */
-      p = find_use_name_n (sym->name, &j, false);
-
-      mio_symbol_interface (&p, &sym->module, &sym->generic);
-    }
+  mio_symbol_interface (&st->name, &sym->module, &sym->generic);
 }
 
 
@@ -4263,7 +4258,7 @@ write_module (void)
   write_char ('\n');
 
   mio_lparen ();
-  gfc_traverse_ns (gfc_current_ns, write_generic);
+  write_generic (gfc_current_ns->sym_root);
   mio_rparen ();
   write_char ('\n');
   write_char ('\n');
index 0a0db6b..ee0d673 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-07  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/34672
+       * gfortran.dg/use_only_2.f90: New test.
+
 2008-01-06  Paolo Carlini  <pcarlini@suse.de>
 
        PR libstdc++/34680
diff --git a/gcc/testsuite/gfortran.dg/use_only_2.f90 b/gcc/testsuite/gfortran.dg/use_only_2.f90
new file mode 100644 (file)
index 0000000..313953e
--- /dev/null
@@ -0,0 +1,30 @@
+! { dg-do compile }
+! Checks the fix for PR34672, in which generic interfaces were not
+! being written correctly, when renamed.
+!
+! Contributed by Jos de Kloe <kloedej@knmi.nl> 
+!
+MODULE MyMod1\r
+  integer, parameter :: i2_ = Selected_Int_Kind(4)\r
+END Module MyMod1\r
+\r
+module MyMod2\r
+  INTERFACE write_int\r
+     module procedure write_int_local\r
+  END INTERFACE\r
+contains\r
+  subroutine write_int_local(value)\r
+    integer, intent(in)  :: value\r
+    print *,value\r
+  end subroutine write_int_local\r
+end module MyMod2\r
+\r
+module MyMod3\r
+  USE MyMod2, only: write_MyInt   => write_int\r
+  USE MyMod1, only: i2_\r
+end module MyMod3\r
+\r
+module MyMod4\r
+  USE MyMod3, only: write_MyInt\r
+end module MYMOD4\r
+! { dg-final { cleanup-modules "MyMod1 MyMod2 MyMod3 MyMod4" } }