This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Fortran,patch] PR 39178 - inline main()


Tobias Burnus wrote:
> Attached the same patch as before - but this time with a changelog and I
> have re-read it :-)

  I correct myself: *this* apparently caused

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40309

  The main function that I see in my final executable looks like this:

(gdb) disass main
Dump of assembler code for function main:
0x0040114d <main+0>:    push   %ebp
0x0040114e <main+1>:    mov    %esp,%ebp
0x00401150 <main+3>:    sub    $0x18,%esp
0x00401153 <main+6>:    mov    0xc(%ebp),%eax
0x00401156 <main+9>:    mov    %eax,0x4(%esp)
0x0040115a <main+13>:   mov    0x8(%ebp),%eax
0x0040115d <main+16>:   mov    %eax,(%esp)
0x00401160 <main+19>:   call   0x402310 <*__gfortran_set_args>
0x00401165 <main+24>:   movl   $0x416b00,0x4(%esp)
0x0040116d <main+32>:   movl   $0x8,(%esp)
0x00401174 <main+39>:   call   0x4023a0 <*__gfortran_set_options>
0x00401179 <main+44>:   call   0x4010e0 <hello>
0x0040117e <main+49>:   mov    $0x0,%eax
0x00401183 <main+54>:   leave
0x00401184 <main+55>:   ret
End of assembler dump.

which looks like the kind of thing that create_main_function would generate,
so isn't it going to be as simple as:

$ svn diff -x -p fortran/trans-decl.c
Index: fortran/trans-decl.c
===================================================================
--- fortran/trans-decl.c        (revision 147949)
+++ fortran/trans-decl.c        (working copy)
@@ -3859,7 +3859,8 @@ create_main_function (tree fndecl)
   tmp =  build_function_type_list (integer_type_node, integer_type_node,
                                   build_pointer_type (pchar_type_node),
                                   NULL_TREE);
-  ftn_main = build_decl (FUNCTION_DECL, get_identifier ("main"), tmp);
+  main_identifier_node
+    = ftn_main = build_decl (FUNCTION_DECL, get_identifier ("main"), tmp);
   DECL_EXTERNAL (ftn_main) = 0;
   TREE_PUBLIC (ftn_main) = 1;
   TREE_STATIC (ftn_main) = 1;


  I'll give that a quick restrap and see if it works.

    cheers,
      DaveK


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]