This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran,patch] Set main_identifier_node
- From: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- To: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 18 Sep 2007 16:55:26 +0100
- Subject: [gfortran,patch] Set main_identifier_node
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.
FX
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;