This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug fortran/40011] Problems with -fwhole-file



------- Comment #65 from burnus at gcc dot gnu dot org  2010-07-24 13:08 -------
(In reply to comment #64)
> Failure with -fwhole-file:
>   /tmp/ccN7F1tB.o: In function `__mod_MOD_four':
>   test.f90:(.text+0x3): undefined reference to `one_'

If one sets a breakpoint in gfc_create_function_decl,
gfc_generate_function_code, and gfc_get_extern_function_decl one has:
...
gfc_get_extern_function_decl "two"
<--- (1) --->
gfc_generate_function_code "two"
...

In between those functions calls, the gfc_global_ns_list changes from:
"two"->"one" to "two"->"MAIN__".

If I add the following patch, it works with the reduced test case and seems to
also work with the one-file CP2K. I wonder why this problem did not show up
before. It seems to be pretty obvious and not restricted to -fwhole-file
(though, the chance of miscompilation is much increased with -fwhole-file).

Index: parse.c
===================================================================
--- parse.c     (Revision 162498)
+++ parse.c     (Arbeitskopie)
@@ -4414,7 +4414,11 @@
      later and all their interfaces resolved.  */   gfc_current_ns->code =
s.head;
   if (next)
-    next->sibling = gfc_current_ns;
+    {
+      for (; next->sibling; next = next->sibling)
+       ;
+      next->sibling = gfc_current_ns;
+    }
   else
     gfc_global_ns_list = gfc_current_ns;


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |burnus at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-12-09 11:50:57         |2010-07-24 13:08:14
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40011


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