OSDN Git Service

fortran/
authoreedelman <eedelman@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Nov 2005 21:40:06 +0000 (21:40 +0000)
committereedelman <eedelman@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Nov 2005 21:40:06 +0000 (21:40 +0000)
2005-11-01  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR 24245
        * trans.c (gfc_generate_code): Move code to create a main
        program symbol from here ...
        * parse.c (main_program_symbol): ... to this new
        function, setting the locus from gfc_current_locus
        instead of ns->code->loc.
        (gfc_parse_file):  Call main_program_symbol for main programs.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106353 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/parse.c
gcc/fortran/trans.c

index d40dff5..7fad64c 100644 (file)
@@ -1,3 +1,13 @@
+2005-11-01  Erik Edelmann  <eedelman@gcc.gnu.org>
+
+       PR 24245
+       * trans.c (gfc_generate_code): Move code to create a main
+       program symbol from here ...
+       * parse.c (main_program_symbol): ... to this new
+       function, setting the locus from gfc_current_locus
+       instead of ns->code->loc.
+       (gfc_parse_file):  Call main_program_symbol for main programs.
+
 2005-11-01  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/24404
index 430d8f3..0fc8f96 100644 (file)
@@ -970,6 +970,28 @@ 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)
+{
+  gfc_symbol *main_program;
+  symbol_attribute attr;
+
+  gfc_get_symbol ("MAIN__", ns, &main_program);
+  gfc_clear_attr (&attr);
+  attr.flavor = FL_PROCEDURE;
+  attr.proc = PROC_UNKNOWN;
+  attr.subroutine = 1;
+  attr.access = ACCESS_PUBLIC;
+  attr.is_main_program = 1;
+  main_program->attr = attr;
+  main_program->declared_at = gfc_current_locus;
+  ns->proc_name = main_program;
+  gfc_commit_symbols ();
+}
+
+
 /* Do whatever is necessary to accept the last statement.  */
 
 static void
@@ -2590,6 +2612,7 @@ loop:
       prog_locus = gfc_current_locus;
 
       push_state (&s, COMP_PROGRAM, gfc_new_block);
+      main_program_symbol(gfc_current_ns);
       accept_statement (st);
       add_global_program ();
       parse_progunit (ST_NONE);
@@ -2631,6 +2654,7 @@ loop:
       prog_locus = gfc_current_locus;
 
       push_state (&s, COMP_PROGRAM, gfc_new_block);
+      main_program_symbol(gfc_current_ns);
       parse_progunit (st);
       break;
     }
index a3c3ddc..5f7c860 100644 (file)
@@ -656,30 +656,6 @@ gfc_generate_code (gfc_namespace * ns)
       return;
     }
 
-  /* Main program subroutine.  */
-  if (!ns->proc_name)
-    {
-      gfc_symbol *main_program;
-      symbol_attribute attr;
-
-      /* Lots of things get upset if a subroutine doesn't have a symbol, so we
-         make one now.  Hopefully we've set all the required fields.  */
-      gfc_get_symbol ("MAIN__", ns, &main_program);
-      gfc_clear_attr (&attr);
-      attr.flavor = FL_PROCEDURE;
-      attr.proc = PROC_UNKNOWN;
-      attr.subroutine = 1;
-      attr.access = ACCESS_PUBLIC;
-      attr.is_main_program = 1;
-      main_program->attr = attr;
-
-      /* Set the location to the first line of code.  */
-      if (ns->code)
-       main_program->declared_at = ns->code->loc;
-      ns->proc_name = main_program;
-      gfc_commit_symbols ();
-    }
-
   gfc_generate_function_code (ns);
 }