Commit ecf24057 by Francois-Xavier Coudert Committed by François-Xavier Coudert

gfortran.h: Shorten comment.

	* gfortran.h: Shorten comment.
	* trans-types.c (gfc_get_function_type): Allow argument to have
	flavor FL_PROGRAM.
	* trans-decl.c (gfc_sym_mangled_function_id): Mangle main program
	name into MAIN__.
	(build_function_decl): Fix comment.
	* parse.c (main_program_symbol): Give the main program its proper
	name, if any. Set its flavor to FL_PROGRAM.
	(gfc_parse_file): Likewise.

From-SVN: r129869
parent 9d85b485
2007-11-03 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* gfortran.h: Shorten comment.
* trans-types.c (gfc_get_function_type): Allow argument to have
flavor FL_PROGRAM.
* trans-decl.c (gfc_sym_mangled_function_id): Mangle main program
name into MAIN__.
(build_function_decl): Fix comment.
* parse.c (main_program_symbol): Give the main program its proper
name, if any. Set its flavor to FL_PROGRAM.
(gfc_parse_file): Likewise.
2007-11-02 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> 2007-11-02 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* intrinsic.texi (ALLOCATED): Fix typo. * intrinsic.texi (ALLOCATED): Fix typo.
......
...@@ -665,9 +665,7 @@ typedef struct ...@@ -665,9 +665,7 @@ typedef struct
/* Set if the symbol has ambiguous interfaces. */ /* Set if the symbol has ambiguous interfaces. */
unsigned ambiguous_interfaces:1; unsigned ambiguous_interfaces:1;
/* Set if the is the symbol for the main program. This is the least /* Set if this is the symbol for the main program. */
cumbersome way to communicate this function property without
strcmp'ing with __MAIN everywhere. */
unsigned is_main_program:1; unsigned is_main_program:1;
/* Mutually exclusive multibit attributes. */ /* Mutually exclusive multibit attributes. */
......
...@@ -1237,14 +1237,14 @@ gfc_ascii_statement (gfc_statement st) ...@@ -1237,14 +1237,14 @@ gfc_ascii_statement (gfc_statement st)
/* Create a symbol for the main program and assign it to ns->proc_name. */ /* Create a symbol for the main program and assign it to ns->proc_name. */
static void static void
main_program_symbol (gfc_namespace *ns) main_program_symbol (gfc_namespace *ns, const char *name)
{ {
gfc_symbol *main_program; gfc_symbol *main_program;
symbol_attribute attr; symbol_attribute attr;
gfc_get_symbol ("MAIN__", ns, &main_program); gfc_get_symbol (name, ns, &main_program);
gfc_clear_attr (&attr); gfc_clear_attr (&attr);
attr.flavor = FL_PROCEDURE; attr.flavor = FL_PROGRAM;
attr.proc = PROC_UNKNOWN; attr.proc = PROC_UNKNOWN;
attr.subroutine = 1; attr.subroutine = 1;
attr.access = ACCESS_PUBLIC; attr.access = ACCESS_PUBLIC;
...@@ -3331,7 +3331,7 @@ loop: ...@@ -3331,7 +3331,7 @@ loop:
prog_locus = gfc_current_locus; prog_locus = gfc_current_locus;
push_state (&s, COMP_PROGRAM, gfc_new_block); push_state (&s, COMP_PROGRAM, gfc_new_block);
main_program_symbol(gfc_current_ns); main_program_symbol(gfc_current_ns, gfc_new_block->name);
accept_statement (st); accept_statement (st);
add_global_program (); add_global_program ();
parse_progunit (ST_NONE); parse_progunit (ST_NONE);
...@@ -3373,7 +3373,7 @@ loop: ...@@ -3373,7 +3373,7 @@ loop:
prog_locus = gfc_current_locus; prog_locus = gfc_current_locus;
push_state (&s, COMP_PROGRAM, gfc_new_block); push_state (&s, COMP_PROGRAM, gfc_new_block);
main_program_symbol (gfc_current_ns); main_program_symbol (gfc_current_ns, "MAIN__");
parse_progunit (st); parse_progunit (st);
break; break;
} }
......
...@@ -7581,6 +7581,9 @@ resolve_symbol (gfc_symbol *sym) ...@@ -7581,6 +7581,9 @@ resolve_symbol (gfc_symbol *sym)
if (sym->attr.procedure && sym->interface if (sym->attr.procedure && sym->interface
&& sym->attr.if_source != IFSRC_DECL) && sym->attr.if_source != IFSRC_DECL)
{ {
while (sym->interface->interface)
sym->interface = sym->interface->interface;
/* Get the attributes from the interface (now resolved). */ /* Get the attributes from the interface (now resolved). */
if (sym->interface->attr.if_source || sym->interface->attr.intrinsic) if (sym->interface->attr.if_source || sym->interface->attr.intrinsic)
{ {
......
...@@ -324,8 +324,12 @@ gfc_sym_mangled_function_id (gfc_symbol * sym) ...@@ -324,8 +324,12 @@ gfc_sym_mangled_function_id (gfc_symbol * sym)
|| (sym->module != NULL && (sym->attr.external || (sym->module != NULL && (sym->attr.external
|| sym->attr.if_source == IFSRC_IFBODY))) || sym->attr.if_source == IFSRC_IFBODY)))
{ {
if (strcmp (sym->name, "MAIN__") == 0 /* Main program is mangled into MAIN__. */
|| sym->attr.proc == PROC_INTRINSIC) if (sym->attr.is_main_program)
return get_identifier ("MAIN__");
/* Intrinsic procedures are never mangled. */
if (sym->attr.proc == PROC_INTRINSIC)
return get_identifier (sym->name); return get_identifier (sym->name);
if (gfc_option.flag_underscoring) if (gfc_option.flag_underscoring)
...@@ -1321,7 +1325,7 @@ build_function_decl (gfc_symbol * sym) ...@@ -1321,7 +1325,7 @@ build_function_decl (gfc_symbol * sym)
TREE_SIDE_EFFECTS (fndecl) = 0; TREE_SIDE_EFFECTS (fndecl) = 0;
} }
/* For -fwhole-program to work well, MAIN__ needs to have the /* For -fwhole-program to work well, the main program needs to have the
"externally_visible" attribute. */ "externally_visible" attribute. */
if (attr.is_main_program) if (attr.is_main_program)
DECL_ATTRIBUTES (fndecl) DECL_ATTRIBUTES (fndecl)
......
...@@ -1924,8 +1924,10 @@ gfc_get_function_type (gfc_symbol * sym) ...@@ -1924,8 +1924,10 @@ gfc_get_function_type (gfc_symbol * sym)
int nstr; int nstr;
int alternate_return; int alternate_return;
/* Make sure this symbol is a function or a subroutine. */ /* Make sure this symbol is a function, a subroutine or the main
gcc_assert (sym->attr.flavor == FL_PROCEDURE); program. */
gcc_assert (sym->attr.flavor == FL_PROCEDURE
|| sym->attr.flavor == FL_PROGRAM);
if (sym->backend_decl) if (sym->backend_decl)
return TREE_TYPE (sym->backend_decl); return TREE_TYPE (sym->backend_decl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment