[gfortran,patch] Set main_identifier_node

François-Xavier Coudert fxcoudert@gmail.com
Tue Sep 18 16:35:00 GMT 2007

Hi all,

I intend to commit the following patch in a few days, unless there are
objections. This allows the middle-end to know that MAIN__ is the main
entry point of the Fortran program. This allows better call graphs to
be generated, e.g. -fwhole-program will not remove it (mostly useless
for now, due to the well-known multiple function decls issue) and
probably allows more correct debug info.

Bootstrapped on x86_64-linux, currently regtesting.


2007-08-18  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

        * parse.c (main_program_symbol): Set main_identifier_node.

Index: gcc/fortran/parse.c
--- gcc/fortran/parse.c (revision 128516)
+++ gcc/fortran/parse.c (working copy)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.

 #include "config.h"
 #include "system.h"
+#include "coretypes.h"
+#include "tree.h"
 #include <setjmp.h>
 #include "gfortran.h"
 #include "match.h"
@@ -1238,6 +1240,9 @@ main_program_symbol (gfc_namespace *ns)
   gfc_symbol *main_program;
   symbol_attribute attr;

+  /* Let backend know that this is the main entry point to the program.  */
+  main_identifier_node = get_identifier ("MAIN__");
   gfc_get_symbol ("MAIN__", ns, &main_program);
   gfc_clear_attr (&attr);
   attr.flavor = FL_PROCEDURE;

More information about the Gcc-patches mailing list