------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-06-06 
00:47 -------
Indeed, this patch seems to fix the problem.  (Untested as of yet, beyond
running the debug.exp tests and the original testcase.)

Joseph, Richard, any thoughts on the appropriateness of this for the C front 
end?

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.660
diff -c -5 -p -r1.660 c-decl.c
*** c-decl.c    28 May 2005 01:38:08 -0000      1.660
--- c-decl.c    6 Jun 2005 00:46:03 -0000
*************** c_write_global_declarations (void)
*** 7548,7570 ****
    /* Close the external scope.  */
    ext_block = pop_scope ();
    external_scope = 0;
    gcc_assert (!current_scope);

-   /* Process all file scopes in this compilation, and the external_scope,
-      through wrapup_global_declarations and check_global_declarations.  */
-   for (t = all_translation_units; t; t = TREE_CHAIN (t))
-     c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
-   c_write_global_declarations_1 (BLOCK_VARS (ext_block));
-
    /* Generate functions to call static constructors and destructors
       for targets that do not support .ctors/.dtors sections.  These
       functions have magic names which are detected by collect2.  */
    build_cdtor ('I', static_ctors); static_ctors = 0;
    build_cdtor ('D', static_dtors); static_dtors = 0;

    /* We're done parsing; proceed to optimize and emit assembly.
       FIXME: shouldn't be the front end's responsibility to call this.  */
    cgraph_optimize ();
  }

  #include "gt-c-decl.h"
--- 7548,7570 ----
    /* Close the external scope.  */
    ext_block = pop_scope ();
    external_scope = 0;
    gcc_assert (!current_scope);

    /* Generate functions to call static constructors and destructors
       for targets that do not support .ctors/.dtors sections.  These
       functions have magic names which are detected by collect2.  */
    build_cdtor ('I', static_ctors); static_ctors = 0;
    build_cdtor ('D', static_dtors); static_dtors = 0;

    /* We're done parsing; proceed to optimize and emit assembly.
       FIXME: shouldn't be the front end's responsibility to call this.  */
    cgraph_optimize ();
+
+   /* Process all file scopes in this compilation, and the external_scope,
+      through wrapup_global_declarations and check_global_declarations.  */
+   for (t = all_translation_units; t; t = TREE_CHAIN (t))
+     c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
+   c_write_global_declarations_1 (BLOCK_VARS (ext_block));
  }

  #include "gt-c-decl.h"


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rth at gcc dot gnu dot org,
                   |                            |joseph at codesourcery dot
                   |                            |com


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

Reply via email to