aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-11-03 14:51:51 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2007-11-03 14:51:51 +0000
commitecf24057f806d6766df43f146ceceac651469430 (patch)
tree0b205366f000dcc61123d9d05537464c13b0f625 /gcc
parent9d85b4853be3eb11746748e20918a9b57480fbab (diff)
downloadgcc-ecf24057f806d6766df43f146ceceac651469430.zip
gcc-ecf24057f806d6766df43f146ceceac651469430.tar.gz
gcc-ecf24057f806d6766df43f146ceceac651469430.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog12
-rw-r--r--gcc/fortran/gfortran.h4
-rw-r--r--gcc/fortran/parse.c10
-rw-r--r--gcc/fortran/resolve.c3
-rw-r--r--gcc/fortran/trans-decl.c10
-rw-r--r--gcc/fortran/trans-types.c6
6 files changed, 32 insertions, 13 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 0810b02..4322dd4 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,15 @@
+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>
* intrinsic.texi (ALLOCATED): Fix typo.
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index bc8fad6..39fd3a1 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -665,9 +665,7 @@ typedef struct
/* Set if the symbol has ambiguous interfaces. */
unsigned ambiguous_interfaces:1;
- /* Set if the is the symbol for the main program. This is the least
- cumbersome way to communicate this function property without
- strcmp'ing with __MAIN everywhere. */
+ /* Set if this is the symbol for the main program. */
unsigned is_main_program:1;
/* Mutually exclusive multibit attributes. */
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index f60ea9a..3e20b78 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -1237,14 +1237,14 @@ gfc_ascii_statement (gfc_statement st)
/* Create a symbol for the main program and assign it to ns->proc_name. */
static void
-main_program_symbol (gfc_namespace *ns)
+main_program_symbol (gfc_namespace *ns, const char *name)
{
gfc_symbol *main_program;
symbol_attribute attr;
- gfc_get_symbol ("MAIN__", ns, &main_program);
+ gfc_get_symbol (name, ns, &main_program);
gfc_clear_attr (&attr);
- attr.flavor = FL_PROCEDURE;
+ attr.flavor = FL_PROGRAM;
attr.proc = PROC_UNKNOWN;
attr.subroutine = 1;
attr.access = ACCESS_PUBLIC;
@@ -3331,7 +3331,7 @@ loop:
prog_locus = gfc_current_locus;
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);
add_global_program ();
parse_progunit (ST_NONE);
@@ -3373,7 +3373,7 @@ loop:
prog_locus = gfc_current_locus;
push_state (&s, COMP_PROGRAM, gfc_new_block);
- main_program_symbol (gfc_current_ns);
+ main_program_symbol (gfc_current_ns, "MAIN__");
parse_progunit (st);
break;
}
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 3542b1e..198fec7 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -7581,6 +7581,9 @@ resolve_symbol (gfc_symbol *sym)
if (sym->attr.procedure && sym->interface
&& sym->attr.if_source != IFSRC_DECL)
{
+ while (sym->interface->interface)
+ sym->interface = sym->interface->interface;
+
/* Get the attributes from the interface (now resolved). */
if (sym->interface->attr.if_source || sym->interface->attr.intrinsic)
{
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 5b6b88b..4b114df 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -324,8 +324,12 @@ gfc_sym_mangled_function_id (gfc_symbol * sym)
|| (sym->module != NULL && (sym->attr.external
|| sym->attr.if_source == IFSRC_IFBODY)))
{
- if (strcmp (sym->name, "MAIN__") == 0
- || sym->attr.proc == PROC_INTRINSIC)
+ /* Main program is mangled into MAIN__. */
+ 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);
if (gfc_option.flag_underscoring)
@@ -1321,7 +1325,7 @@ build_function_decl (gfc_symbol * sym)
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. */
if (attr.is_main_program)
DECL_ATTRIBUTES (fndecl)
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index e836861..88066a3 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -1924,8 +1924,10 @@ gfc_get_function_type (gfc_symbol * sym)
int nstr;
int alternate_return;
- /* Make sure this symbol is a function or a subroutine. */
- gcc_assert (sym->attr.flavor == FL_PROCEDURE);
+ /* Make sure this symbol is a function, a subroutine or the main
+ program. */
+ gcc_assert (sym->attr.flavor == FL_PROCEDURE
+ || sym->attr.flavor == FL_PROGRAM);
if (sym->backend_decl)
return TREE_TYPE (sym->backend_decl);