]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/26682 (gfortran fails with -fwhole-program optimization)
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 3 Oct 2007 21:27:39 +0000 (21:27 +0000)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 3 Oct 2007 21:27:39 +0000 (21:27 +0000)
PR fortran/26682
* trans-decl.c (build_function_decl): Set "externally_visible"
attribute on the MAIN program decl.

From-SVN: r128993

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c

index 226c50a20fee841c70f9dfad7d2c304c7d70d058..cb9c9ca964f0276fec908156b8d5fc9d80f95c2f 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-03  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/26682
+       * trans-decl.c (build_function_decl): Set "externally_visible"
+       attribute on the MAIN program decl.
+
 2007-10-03  Tobias Schlüter  <tobi@gcc.gnu.org>
 
        PR fortran/33198
index f04a4d1b90402fce18cf4eea03dd09cf4400f89f..5b6b88bde631c0500d0e3ddc42325d320a383c4e 100644 (file)
@@ -1321,6 +1321,12 @@ build_function_decl (gfc_symbol * sym)
       TREE_SIDE_EFFECTS (fndecl) = 0;
     }
 
+  /* For -fwhole-program to work well, MAIN__ needs to have the
+     "externally_visible" attribute.  */
+  if (attr.is_main_program)
+    DECL_ATTRIBUTES (fndecl)
+      = tree_cons (get_identifier("externally_visible"), NULL_TREE, NULL_TREE);
+
   /* Layout the function declaration and put it in the binding level
      of the current function.  */
   pushdecl (fndecl);